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