| 1 |
//===----------------------------------------------------------------------===// |
| 2 |
// |
| 3 |
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 |
// See https://llvm.org/LICENSE.txt for license information. |
| 5 |
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 |
// |
| 7 |
//===----------------------------------------------------------------------===// |
| 8 |
|
| 9 |
// <array> |
| 10 |
|
| 11 |
// template <size_t I, class T, size_t N> const T&& get(const array<T, N>&& a); |
| 12 |
|
| 13 |
// UNSUPPORTED: c++03 |
| 14 |
|
| 15 |
#include <array> |
| 16 |
#include <memory> |
| 17 |
#include <type_traits> |
| 18 |
#include <utility> |
| 19 |
#include <cassert> |
| 20 |
|
| 21 |
#include "test_macros.h" |
| 22 |
|
| 23 |
int main(int, char**) |
| 24 |
{ |
| 25 |
|
| 26 |
{ |
| 27 |
typedef std::unique_ptr<double> T; |
| 28 |
typedef std::array<T, 1> C; |
| 29 |
const C c = {std::unique_ptr<double>(new double(3.5))}; |
| 30 |
static_assert(std::is_same<const T&&, decltype(std::get<0>(std::move(c)))>::value, ""); |
| 31 |
static_assert(noexcept(std::get<0>(std::move(c))), ""); |
| 32 |
const T&& t = std::get<0>(std::move(c)); |
| 33 |
assert(*t == 3.5); |
| 34 |
} |
| 35 |
|
| 36 |
#if TEST_STD_VER >= 14 |
| 37 |
{ |
| 38 |
typedef double T; |
| 39 |
typedef std::array<T, 3> C; |
| 40 |
constexpr const C c = {1, 2, 3.5}; |
| 41 |
static_assert(std::get<0>(std::move(c)) == 1, ""); |
| 42 |
static_assert(std::get<1>(std::move(c)) == 2, ""); |
| 43 |
static_assert(std::get<2>(std::move(c)) == 3.5, ""); |
| 44 |
} |
| 45 |
#endif |
| 46 |
|
| 47 |
return 0; |
| 48 |
} |