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