tuple_size.pass.cpp 1.4 KB

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