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 #include <array> 14 #include <cassert> 15 16 #include "test_macros.h" 17 18 // std::array is explicitly allowed to be initialized with A a = { init-list };. 19 // Disable the missing braces warning for this reason. 20 #include "disable_missing_braces_warning.h" 21 22 int main(int, char**) 23 { 24 { 25 typedef double T; 26 typedef std::array<T, 3> C; 27 const C c = {1, 2, 3.5}; 28 assert(std::get<0>(c) == 1); 29 assert(std::get<1>(c) == 2); 30 assert(std::get<2>(c) == 3.5); 31 } 32 #if TEST_STD_VER > 11 33 { 34 typedef double T; 35 typedef std::array<T, 3> C; 36 constexpr const C c = {1, 2, 3.5}; 37 static_assert(std::get<0>(c) == 1, ""); 38 static_assert(std::get<1>(c) == 2, ""); 39 static_assert(std::get<2>(c) == 3.5, ""); 40 } 41 #endif 42 43 return 0; 44 } 45