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 <class... Types>
15 //   class tuple_size<tuple<Types...>>
16 //     : public integral_constant<size_t, sizeof...(Types)> { };
17 //
18 //  LWG #2212 says that tuple_size and tuple_element must be
19 //     available after including <utility>
20 
21 #include <utility>
22 #include <type_traits>
23 
24 template <class T, std::size_t N, class U, size_t idx>
test()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 
main()41 int main()
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