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