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