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 <type_traits>
16#include <utility>
17
18template <class T1, class T2>
19void 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
51int main(int, char**)
52{
53 test<int, short>();
54 test<int*, char>();
55
56 return 0;
57}
58

source code of libcxx/test/std/utilities/utility/pairs/pair.astuple/tuple_element.pass.cpp