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> T& get(array<T, N>& a);
13 
14 #include <array>
15 #include <cassert>
16 
17 #include "test_macros.h"
18 
19 #include "../suppress_array_warnings.h"
20 
21 
22 #if TEST_STD_VER > 11
23 struct S {
24    std::array<int, 3> a;
25    int k;
SS26    constexpr S() : a{1,2,3}, k(std::get<2>(a)) {}
27 };
28 
getArr()29 constexpr std::array<int, 2> getArr () { return { 3, 4 }; }
30 #endif
31 
main()32 int main()
33 {
34     {
35         typedef double T;
36         typedef std::array<T, 3> C;
37         C c = {1, 2, 3.5};
38         std::get<1>(c) = 5.5;
39         assert(c[0] == 1);
40         assert(c[1] == 5.5);
41         assert(c[2] == 3.5);
42     }
43 #if TEST_STD_VER > 11
44     {
45         typedef double T;
46         typedef std::array<T, 3> C;
47         constexpr C c = {1, 2, 3.5};
48         static_assert(std::get<0>(c) == 1, "");
49         static_assert(std::get<1>(c) == 2, "");
50         static_assert(std::get<2>(c) == 3.5, "");
51     }
52     {
53         static_assert(S().k == 3, "");
54         static_assert(std::get<1>(getArr()) == 4, "");
55     }
56 #endif
57 }
58