tuple_size.pass.cpp revision b64f8b07c104c6cc986570ac8ee0ed16a9f23976
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#include <tuple>
19#include <type_traits>
20
21int main()
22{
23    {
24        typedef std::tuple<> T;
25        static_assert((std::is_base_of<std::integral_constant<std::size_t, 0>,
26                                      std::tuple_size<T> >::value), "");
27    }
28    {
29        typedef std::tuple<int> T;
30        static_assert((std::is_base_of<std::integral_constant<std::size_t, 1>,
31                                      std::tuple_size<T> >::value), "");
32    }
33    {
34        typedef std::tuple<char, int> T;
35        static_assert((std::is_base_of<std::integral_constant<std::size_t, 2>,
36                                      std::tuple_size<T> >::value), "");
37    }
38    {
39        typedef std::tuple<char, char*, int> T;
40        static_assert((std::is_base_of<std::integral_constant<std::size_t, 3>,
41                                      std::tuple_size<T> >::value), "");
42    }
43}
44