diff options
author | Eric Fiselier <eric@efcs.ca> | 2017-01-02 23:54:13 +0000 |
---|---|---|
committer | Eric Fiselier <eric@efcs.ca> | 2017-01-02 23:54:13 +0000 |
commit | 1013fe3c0cfd7582e94ef2d4bfd79da7ea1a1289 (patch) | |
tree | 570684bb1eddd70784f35953e4b830a73d31a2bc /libcxx/test/std/utilities/tuple | |
parent | 9877c1e71387c7a060095e228e1f7a1e65c18e52 (diff) | |
download | bcm5719-llvm-1013fe3c0cfd7582e94ef2d4bfd79da7ea1a1289.tar.gz bcm5719-llvm-1013fe3c0cfd7582e94ef2d4bfd79da7ea1a1289.zip |
Re-implement LWG 2770 - Fix tuple_size with structured bindings.
This patch implements the correct PR for LWG 2770. It also makes the primary
tuple_size template incomplete again which fixes part of llvm.org/PR31513.
llvm-svn: 290846
Diffstat (limited to 'libcxx/test/std/utilities/tuple')
3 files changed, 16 insertions, 24 deletions
diff --git a/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.fail.cpp b/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.fail.cpp index 50c6f17efbe..3f132e47b62 100644 --- a/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.fail.cpp +++ b/libcxx/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 {{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'}} + (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}} } diff --git a/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.pass.cpp b/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.pass.cpp index 40214f632e7..3e4145c79cb 100644 --- a/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.pass.cpp +++ b/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size.pass.cpp @@ -18,8 +18,6 @@ // UNSUPPORTED: c++98, c++03 #include <tuple> -#include <utility> -#include <array> #include <type_traits> template <class T, class = decltype(std::tuple_size<T>::value)> @@ -27,27 +25,29 @@ 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); } +struct Dummy {}; 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 *>(), ""); - } +} + +void test_tuple_size_value_sfinae() { + // Test that the ::value member does not exist + static_assert(has_value<std::tuple<int> const>(), ""); + static_assert(has_value<std::pair<int, long> volatile>(), ""); + static_assert(!has_value<int>(), ""); + static_assert(!has_value<const int>(), ""); + static_assert(!has_value<volatile void>(), ""); + static_assert(!has_value<const volatile std::tuple<int>&>(), ""); } int main() @@ -56,13 +56,5 @@ 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>&>(), ""); - } + test_tuple_size_value_sfinae(); } diff --git a/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_v.fail.cpp b/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_v.fail.cpp index 700dd95c959..957a683b47f 100644 --- a/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.helper/tuple_size_v.fail.cpp +++ b/libcxx/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 {{no member named 'value'}} + // expected-error@tuple:* 3 {{implicit instantiation of undefined template}} } |