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 <class... Types> 14 // class tuple_size<tuple<Types...>> 15 // : public integral_constant<size_t, sizeof...(Types)> { }; 16 // 17 // LWG #2212 says that tuple_size and tuple_element must be 18 // available after including <utility> 19 20 #include <cstddef> 21 #include <utility> 22 #include <type_traits> 23 24 template <class T, std::size_t N, class U, size_t idx> 25 void test() 26 { 27 static_assert((std::is_base_of<std::integral_constant<std::size_t, N>, 28 std::tuple_size<T> >::value), ""); 29 static_assert((std::is_base_of<std::integral_constant<std::size_t, N>, 30 std::tuple_size<const T> >::value), ""); 31 static_assert((std::is_base_of<std::integral_constant<std::size_t, N>, 32 std::tuple_size<volatile T> >::value), ""); 33 static_assert((std::is_base_of<std::integral_constant<std::size_t, N>, 34 std::tuple_size<const volatile T> >::value), ""); 35 static_assert((std::is_same<typename std::tuple_element<idx, T>::type, U>::value), ""); 36 static_assert((std::is_same<typename std::tuple_element<idx, const T>::type, const U>::value), ""); 37 static_assert((std::is_same<typename std::tuple_element<idx, volatile T>::type, volatile U>::value), ""); 38 static_assert((std::is_same<typename std::tuple_element<idx, const volatile T>::type, const volatile U>::value), ""); 39 } 40 41 int main(int, char**) 42 { 43 test<std::pair<int, int>, 2, int, 0>(); 44 test<std::pair<int, int>, 2, int, 1>(); 45 test<std::pair<const int, int>, 2, int, 1>(); 46 test<std::pair<int, volatile int>, 2, volatile int, 1>(); 47 test<std::pair<char *, int>, 2, char *, 0>(); 48 test<std::pair<char *, int>, 2, int, 1>(); 49 50 return 0; 51 } 52