tuple_size.pass.cpp revision 86ed8aefb29692a231ce218815ad1077f2329cc5
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 21template <class T, std::size_t N> 22void test() 23{ 24 static_assert((std::is_base_of<std::integral_constant<std::size_t, N>, 25 std::tuple_size<T> >::value), ""); 26 static_assert((std::is_base_of<std::integral_constant<std::size_t, N>, 27 std::tuple_size<const T> >::value), ""); 28 static_assert((std::is_base_of<std::integral_constant<std::size_t, N>, 29 std::tuple_size<volatile T> >::value), ""); 30 static_assert((std::is_base_of<std::integral_constant<std::size_t, N>, 31 std::tuple_size<const volatile T> >::value), ""); 32} 33 34int main() 35{ 36 test<std::tuple<>, 0>(); 37 test<std::tuple<int>, 1>(); 38 test<std::tuple<char, int>, 2>(); 39 test<std::tuple<char, char*, int>, 3>(); 40} 41