• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===----------------------------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 // <array>
11 
12 // template <size_t I, class T, size_t N> const T&& get(const array<T, N>&& a);
13 
14 // UNSUPPORTED: c++98, c++03
15 
16 #include <array>
17 #include <memory>
18 #include <type_traits>
19 #include <utility>
20 #include <cassert>
21 
22 #include "test_macros.h"
23 
24 // std::array is explicitly allowed to be initialized with A a = { init-list };.
25 // Disable the missing braces warning for this reason.
26 #include "disable_missing_braces_warning.h"
27 
main()28 int main()
29 {
30 
31     {
32     typedef std::unique_ptr<double> T;
33     typedef std::array<T, 1> C;
34     const C c = {std::unique_ptr<double>(new double(3.5))};
35     static_assert(std::is_same<const T&&, decltype(std::get<0>(std::move(c)))>::value, "");
36     static_assert(noexcept(std::get<0>(std::move(c))), "");
37     const T&& t = std::get<0>(std::move(c));
38     assert(*t == 3.5);
39     }
40 
41 #if TEST_STD_VER > 11
42     {
43     typedef double T;
44     typedef std::array<T, 3> C;
45     constexpr const C c = {1, 2, 3.5};
46     static_assert(std::get<0>(std::move(c)) == 1, "");
47     static_assert(std::get<1>(std::move(c)) == 2, "");
48     static_assert(std::get<2>(std::move(c)) == 3.5, "");
49     }
50 #endif
51 }
52