Home | History | Annotate | Download | only in pair.astuple
      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 // <utility>
     11 
     12 // template <class T1, class T2> struct pair
     13 
     14 // tuple_element<I, pair<T1, T2> >::type
     15 
     16 #include <utility>
     17 
     18 template <class T1, class T2>
     19 void test()
     20 {
     21     {
     22     typedef T1 Exp1;
     23     typedef T2 Exp2;
     24     typedef std::pair<T1, T2> P;
     25     static_assert((std::is_same<typename std::tuple_element<0, P>::type, Exp1>::value), "");
     26     static_assert((std::is_same<typename std::tuple_element<1, P>::type, Exp2>::value), "");
     27     }
     28     {
     29     typedef T1 const Exp1;
     30     typedef T2 const Exp2;
     31     typedef std::pair<T1, T2> const P;
     32     static_assert((std::is_same<typename std::tuple_element<0, P>::type, Exp1>::value), "");
     33     static_assert((std::is_same<typename std::tuple_element<1, P>::type, Exp2>::value), "");
     34     }
     35     {
     36     typedef T1 volatile Exp1;
     37     typedef T2 volatile Exp2;
     38     typedef std::pair<T1, T2> volatile P;
     39     static_assert((std::is_same<typename std::tuple_element<0, P>::type, Exp1>::value), "");
     40     static_assert((std::is_same<typename std::tuple_element<1, P>::type, Exp2>::value), "");
     41     }
     42     {
     43     typedef T1 const volatile Exp1;
     44     typedef T2 const volatile Exp2;
     45     typedef std::pair<T1, T2> const volatile P;
     46     static_assert((std::is_same<typename std::tuple_element<0, P>::type, Exp1>::value), "");
     47     static_assert((std::is_same<typename std::tuple_element<1, P>::type, Exp2>::value), "");
     48     }
     49 }
     50 
     51 int main()
     52 {
     53     test<int, short>();
     54     test<int*, char>();
     55 }
     56