From f613e60d0d7208a872de09825cab7c5efc5616d5 Mon Sep 17 00:00:00 2001 From: Michael Schellenberger Costa Date: Wed, 9 Jun 2021 13:14:00 +0200 Subject: [PATCH 1/3] Adopt LWG-3541 This makes indirectly_readable_traits SFINAE friendly and adds some tests for that Addresses #1965 --- stl/inc/xutility | 4 +++ stl/inc/yvals_core.h | 1 + .../test.cpp | 29 +++++++++++++++++++ 3 files changed, 34 insertions(+) diff --git a/stl/inc/xutility b/stl/inc/xutility index 68fd05a7463..d5c4d62190b 100644 --- a/stl/inc/xutility +++ b/stl/inc/xutility @@ -431,6 +431,10 @@ template <_Has_member_element_type _Ty> struct indirectly_readable_traits<_Ty> : _Cond_value_type {}; // clang-format off +template <_Has_member_value_type _Ty> + requires _Has_member_element_type<_Ty> +struct indirectly_readable_traits<_Ty> {}; + template <_Has_member_value_type _Ty> requires _Has_member_element_type<_Ty> && same_as, remove_cv_t> diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index 3b2c62061be..c0c30c41c9f 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -249,6 +249,7 @@ // _HAS_CXX20 indirectly controls: // P0619R4 Removing C++17-Deprecated Features +// LWG-3541 indirectly_readable_traits should be SFINAE-friendly for all types // _HAS_CXX20 and _SILENCE_ALL_CXX20_DEPRECATION_WARNINGS control: // P0767R1 Deprecating is_pod diff --git a/tests/std/tests/P0896R4_ranges_iterator_machinery/test.cpp b/tests/std/tests/P0896R4_ranges_iterator_machinery/test.cpp index 9429d072929..98aede61faf 100644 --- a/tests/std/tests/P0896R4_ranges_iterator_machinery/test.cpp +++ b/tests/std/tests/P0896R4_ranges_iterator_machinery/test.cpp @@ -3370,6 +3370,35 @@ namespace vso1121031 { STATIC_ASSERT(!has_member_value_type>>); } // namespace vso1121031 +namespace lwg3541 { + // Make indirectly_readable_traits SFINAE friendly + using std::indirectly_readable_traits, std::same_as; + + template + struct iterish { + using value_type = int; + using element_type = Element; + }; + + template + struct SFINAE {}; + + // Specialization only available for T which respect the traits. + template + struct SFINAE>>>> { + using value_type = typename indirectly_readable_traits>::value_type; + }; + STATIC_ASSERT(same_as::value_type, int>); + STATIC_ASSERT(same_as::value_type, int>); + STATIC_ASSERT(same_as::value_type, int>); + STATIC_ASSERT(same_as::value_type, int>); + + STATIC_ASSERT(!has_member_value_type>); + STATIC_ASSERT(!has_member_value_type>); + STATIC_ASSERT(!has_member_value_type>); + STATIC_ASSERT(!has_member_value_type>); +} // namespace lwg3541 + int main() { iterator_cust_swap_test::test(); iter_ops::test(); From a42c94598d9b9eb2501bd5dc5e9bb2ecaa167aaf Mon Sep 17 00:00:00 2001 From: Michael Schellenberger Costa Date: Thu, 10 Jun 2021 13:59:02 +0200 Subject: [PATCH 2/3] drop mentions in yvals_core --- stl/inc/yvals_core.h | 1 - 1 file changed, 1 deletion(-) diff --git a/stl/inc/yvals_core.h b/stl/inc/yvals_core.h index c0c30c41c9f..3b2c62061be 100644 --- a/stl/inc/yvals_core.h +++ b/stl/inc/yvals_core.h @@ -249,7 +249,6 @@ // _HAS_CXX20 indirectly controls: // P0619R4 Removing C++17-Deprecated Features -// LWG-3541 indirectly_readable_traits should be SFINAE-friendly for all types // _HAS_CXX20 and _SILENCE_ALL_CXX20_DEPRECATION_WARNINGS control: // P0767R1 Deprecating is_pod From 692b2d3ba7203b1cc36bc6c2fb354a0dfb341f0a Mon Sep 17 00:00:00 2001 From: Michael Schellenberger Costa Date: Wed, 23 Jun 2021 11:34:05 +0200 Subject: [PATCH 3/3] Remove duplicated tests --- .../test.cpp | 29 ------------------- 1 file changed, 29 deletions(-) diff --git a/tests/std/tests/P0896R4_ranges_iterator_machinery/test.cpp b/tests/std/tests/P0896R4_ranges_iterator_machinery/test.cpp index 98aede61faf..9429d072929 100644 --- a/tests/std/tests/P0896R4_ranges_iterator_machinery/test.cpp +++ b/tests/std/tests/P0896R4_ranges_iterator_machinery/test.cpp @@ -3370,35 +3370,6 @@ namespace vso1121031 { STATIC_ASSERT(!has_member_value_type>>); } // namespace vso1121031 -namespace lwg3541 { - // Make indirectly_readable_traits SFINAE friendly - using std::indirectly_readable_traits, std::same_as; - - template - struct iterish { - using value_type = int; - using element_type = Element; - }; - - template - struct SFINAE {}; - - // Specialization only available for T which respect the traits. - template - struct SFINAE>>>> { - using value_type = typename indirectly_readable_traits>::value_type; - }; - STATIC_ASSERT(same_as::value_type, int>); - STATIC_ASSERT(same_as::value_type, int>); - STATIC_ASSERT(same_as::value_type, int>); - STATIC_ASSERT(same_as::value_type, int>); - - STATIC_ASSERT(!has_member_value_type>); - STATIC_ASSERT(!has_member_value_type>); - STATIC_ASSERT(!has_member_value_type>); - STATIC_ASSERT(!has_member_value_type>); -} // namespace lwg3541 - int main() { iterator_cust_swap_test::test(); iter_ops::test();