xref: /llvm-project/libcxx/test/std/containers/sequences/array/array.tuple/get_const.pass.cpp (revision 2decfad7c5df07030c27e70b98ca9feada760d3c)
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 #include <array>
15 #include <cassert>
16 
17 #include "test_macros.h"
18 
19 #include "../suppress_array_warnings.h"
20 
21 int main()
22 {
23     {
24         typedef double T;
25         typedef std::array<T, 3> C;
26         const C c = {1, 2, 3.5};
27         assert(std::get<0>(c) == 1);
28         assert(std::get<1>(c) == 2);
29         assert(std::get<2>(c) == 3.5);
30     }
31 #if TEST_STD_VER > 11
32     {
33         typedef double T;
34         typedef std::array<T, 3> C;
35         constexpr const C c = {1, 2, 3.5};
36         static_assert(std::get<0>(c) == 1, "");
37         static_assert(std::get<1>(c) == 2, "");
38         static_assert(std::get<2>(c) == 3.5, "");
39     }
40 #endif
41 }
42