tuple_size.pass.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. // <tuple>
  10. // template <class... Types> class tuple;
  11. // template <class... Types>
  12. // class tuple_size<tuple<Types...>>
  13. // : public integral_constant<size_t, sizeof...(Types)> { };
  14. // UNSUPPORTED: c++98, c++03
  15. #include <tuple>
  16. #include <type_traits>
  17. template <class T, std::size_t N>
  18. void test()
  19. {
  20. static_assert((std::is_base_of<std::integral_constant<std::size_t, N>,
  21. std::tuple_size<T> >::value), "");
  22. static_assert((std::is_base_of<std::integral_constant<std::size_t, N>,
  23. std::tuple_size<const T> >::value), "");
  24. static_assert((std::is_base_of<std::integral_constant<std::size_t, N>,
  25. std::tuple_size<volatile T> >::value), "");
  26. static_assert((std::is_base_of<std::integral_constant<std::size_t, N>,
  27. std::tuple_size<const volatile T> >::value), "");
  28. }
  29. int main()
  30. {
  31. test<std::tuple<>, 0>();
  32. test<std::tuple<int>, 1>();
  33. test<std::tuple<char, int>, 2>();
  34. test<std::tuple<char, char*, int>, 3>();
  35. }