• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "test_macros.h"
18 
19 template <class T1, class T2>
test()20 void test()
21 {
22     {
23     typedef T1 Exp1;
24     typedef T2 Exp2;
25     typedef std::pair<T1, T2> P;
26     static_assert((std::is_same<typename std::tuple_element<0, P>::type, Exp1>::value), "");
27     static_assert((std::is_same<typename std::tuple_element<1, P>::type, Exp2>::value), "");
28     }
29     {
30     typedef T1 const Exp1;
31     typedef T2 const Exp2;
32     typedef std::pair<T1, T2> const P;
33     static_assert((std::is_same<typename std::tuple_element<0, P>::type, Exp1>::value), "");
34     static_assert((std::is_same<typename std::tuple_element<1, P>::type, Exp2>::value), "");
35     }
36     {
37     typedef T1 volatile Exp1;
38     typedef T2 volatile Exp2;
39     typedef std::pair<T1, T2> volatile P;
40     static_assert((std::is_same<typename std::tuple_element<0, P>::type, Exp1>::value), "");
41     static_assert((std::is_same<typename std::tuple_element<1, P>::type, Exp2>::value), "");
42     }
43     {
44     typedef T1 const volatile Exp1;
45     typedef T2 const volatile Exp2;
46     typedef std::pair<T1, T2> const volatile P;
47     static_assert((std::is_same<typename std::tuple_element<0, P>::type, Exp1>::value), "");
48     static_assert((std::is_same<typename std::tuple_element<1, P>::type, Exp2>::value), "");
49     }
50 }
51 
main(int,char **)52 int main(int, char**)
53 {
54     test<int, short>();
55     test<int*, char>();
56 
57   return 0;
58 }
59