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 // tuple_element<I, array<T, N> >::type
     13 
     14 #include <array>
     15 #include <type_traits>
     16 
     17 template <class T>
     18 void test()
     19 {
     20     {
     21     typedef T Exp;
     22     typedef std::array<T, 3> C;
     23     static_assert((std::is_same<typename std::tuple_element<0, C>::type, Exp>::value), "");
     24     static_assert((std::is_same<typename std::tuple_element<1, C>::type, Exp>::value), "");
     25     static_assert((std::is_same<typename std::tuple_element<2, C>::type, Exp>::value), "");
     26     }
     27     {
     28     typedef T const Exp;
     29     typedef std::array<T, 3> const C;
     30     static_assert((std::is_same<typename std::tuple_element<0, C>::type, Exp>::value), "");
     31     static_assert((std::is_same<typename std::tuple_element<1, C>::type, Exp>::value), "");
     32     static_assert((std::is_same<typename std::tuple_element<2, C>::type, Exp>::value), "");
     33     }
     34     {
     35     typedef T volatile Exp;
     36     typedef std::array<T, 3> volatile C;
     37     static_assert((std::is_same<typename std::tuple_element<0, C>::type, Exp>::value), "");
     38     static_assert((std::is_same<typename std::tuple_element<1, C>::type, Exp>::value), "");
     39     static_assert((std::is_same<typename std::tuple_element<2, C>::type, Exp>::value), "");
     40     }
     41     {
     42     typedef T const volatile Exp;
     43     typedef std::array<T, 3> const volatile C;
     44     static_assert((std::is_same<typename std::tuple_element<0, C>::type, Exp>::value), "");
     45     static_assert((std::is_same<typename std::tuple_element<1, C>::type, Exp>::value), "");
     46     static_assert((std::is_same<typename std::tuple_element<2, C>::type, Exp>::value), "");
     47     }
     48 }
     49 
     50 int main()
     51 {
     52     test<double>();
     53     test<int>();
     54 }
     55