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 // <tuple>
11
12 // template <class... Types> class tuple;
13
14 // template <size_t I, class... Types>
15 // class tuple_element<I, tuple<Types...> >
16 // {
17 // public:
18 // typedef Ti type;
19 // };
20
21 // UNSUPPORTED: c++98, c++03
22
23 #include <tuple>
24 #include <type_traits>
25
26 #include "test_macros.h"
27
28 template <class T, std::size_t N, class U>
test()29 void test()
30 {
31 static_assert((std::is_same<typename std::tuple_element<N, T>::type, U>::value), "");
32 static_assert((std::is_same<typename std::tuple_element<N, const T>::type, const U>::value), "");
33 static_assert((std::is_same<typename std::tuple_element<N, volatile T>::type, volatile U>::value), "");
34 static_assert((std::is_same<typename std::tuple_element<N, const volatile T>::type, const volatile U>::value), "");
35 #if TEST_STD_VER > 11
36 static_assert((std::is_same<typename std::tuple_element_t<N, T>, U>::value), "");
37 static_assert((std::is_same<typename std::tuple_element_t<N, const T>, const U>::value), "");
38 static_assert((std::is_same<typename std::tuple_element_t<N, volatile T>, volatile U>::value), "");
39 static_assert((std::is_same<typename std::tuple_element_t<N, const volatile T>, const volatile U>::value), "");
40 #endif
41 }
42
main()43 int main()
44 {
45 test<std::tuple<int>, 0, int>();
46 test<std::tuple<char, int>, 0, char>();
47 test<std::tuple<char, int>, 1, int>();
48 test<std::tuple<int*, char, int>, 0, int*>();
49 test<std::tuple<int*, char, int>, 1, char>();
50 test<std::tuple<int*, char, int>, 2, int>();
51 }
52