diff options
Diffstat (limited to 'test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.pass.cpp')
| -rw-r--r-- | test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.pass.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.pass.cpp index 49b4215a1956..40214f632e75 100644 --- a/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.pass.cpp +++ b/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.pass.cpp @@ -18,19 +18,36 @@ // UNSUPPORTED: c++98, c++03 #include <tuple> +#include <utility> +#include <array> #include <type_traits> +template <class T, class = decltype(std::tuple_size<T>::value)> +constexpr bool has_value(int) { return true; } +template <class> constexpr bool has_value(long) { return false; } +template <class T> constexpr bool has_value() { return has_value<T>(0); } + + template <class T, std::size_t N> void test() { + static_assert(has_value<T>(), ""); static_assert((std::is_base_of<std::integral_constant<std::size_t, N>, std::tuple_size<T> >::value), ""); + static_assert(has_value<const T>(), ""); static_assert((std::is_base_of<std::integral_constant<std::size_t, N>, std::tuple_size<const T> >::value), ""); + static_assert(has_value<volatile T>(), ""); static_assert((std::is_base_of<std::integral_constant<std::size_t, N>, std::tuple_size<volatile T> >::value), ""); + + static_assert(has_value<const volatile T>(), ""); static_assert((std::is_base_of<std::integral_constant<std::size_t, N>, std::tuple_size<const volatile T> >::value), ""); + { + static_assert(!has_value<T &>(), ""); + static_assert(!has_value<T *>(), ""); + } } int main() @@ -39,4 +56,13 @@ int main() test<std::tuple<int>, 1>(); test<std::tuple<char, int>, 2>(); test<std::tuple<char, char*, int>, 3>(); + test<std::pair<int, void*>, 2>(); + test<std::array<int, 42>, 42>(); + { + static_assert(!has_value<void>(), ""); + static_assert(!has_value<void*>(), ""); + static_assert(!has_value<int>(), ""); + static_assert(!has_value<std::pair<int, int>*>(), ""); + static_assert(!has_value<std::array<int, 42>&>(), ""); + } } |
