diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2017-01-02 19:18:58 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2017-01-02 19:18:58 +0000 |
| commit | 53a420fba21cf1644972b34dcd811a43cdb8368d (patch) | |
| tree | 66a19f6f8b65215772549a51d688492ab8addc0d /test/std/utilities/tuple/tuple.tuple/tuple.helper | |
| parent | b50f1549701eb950921e5d6f2e55ba1a1dadbb43 (diff) | |
Notes
Diffstat (limited to 'test/std/utilities/tuple/tuple.tuple/tuple.helper')
4 files changed, 33 insertions, 5 deletions
diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_element.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_element.pass.cpp index 42e4fab88ffa..5beedbe9d157 100644 --- a/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_element.pass.cpp +++ b/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_element.pass.cpp @@ -23,6 +23,8 @@ #include <tuple> #include <type_traits> +#include "test_macros.h" + template <class T, std::size_t N, class U> void test() { @@ -30,7 +32,7 @@ void test() static_assert((std::is_same<typename std::tuple_element<N, const T>::type, const U>::value), ""); static_assert((std::is_same<typename std::tuple_element<N, volatile T>::type, volatile U>::value), ""); static_assert((std::is_same<typename std::tuple_element<N, const volatile T>::type, const volatile U>::value), ""); -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 static_assert((std::is_same<typename std::tuple_element_t<N, T>, U>::value), ""); static_assert((std::is_same<typename std::tuple_element_t<N, const T>, const U>::value), ""); static_assert((std::is_same<typename std::tuple_element_t<N, volatile T>, volatile U>::value), ""); diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.fail.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.fail.cpp index 3f132e47b626..50c6f17efbef 100644 --- a/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.fail.cpp +++ b/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.fail.cpp @@ -21,7 +21,7 @@ int main() { - (void)std::tuple_size<std::tuple<> &>::value; // expected-error {{implicit instantiation of undefined template}} - (void)std::tuple_size<int>::value; // expected-error {{implicit instantiation of undefined template}} - (void)std::tuple_size<std::tuple<>*>::value; // expected-error {{implicit instantiation of undefined template}} + (void)std::tuple_size<std::tuple<> &>::value; // expected-error {{no member named 'value'}} + (void)std::tuple_size<int>::value; // expected-error {{no member named 'value'}} + (void)std::tuple_size<std::tuple<>*>::value; // expected-error {{no member named 'value'}} } 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>&>(), ""); + } } diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_v.fail.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_v.fail.cpp index 957a683b47f8..700dd95c959c 100644 --- a/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_v.fail.cpp +++ b/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_v.fail.cpp @@ -22,5 +22,5 @@ int main() (void)std::tuple_size_v<std::tuple<> &>; // expected-note {{requested here}} (void)std::tuple_size_v<int>; // expected-note {{requested here}} (void)std::tuple_size_v<std::tuple<>*>; // expected-note {{requested here}} - // expected-error@tuple:* 3 {{implicit instantiation of undefined template}} + // expected-error@tuple:* 3 {{no member named 'value'}} } |
