From 4b48ee16c25cc7aa24ac1fc66ca9d6cfdb581e91 Mon Sep 17 00:00:00 2001 From: Igor Zhukov Date: Mon, 13 Dec 2021 19:02:19 +0700 Subject: [PATCH 1/3] modify convertible-to-non-slicing --- stl/inc/xutility | 9 ++++++--- .../tests/P0896R4_ranges_subrange/test.compile.pass.cpp | 6 ++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/stl/inc/xutility b/stl/inc/xutility index 6176fa1c5cc..6d917b6a19d 100644 --- a/stl/inc/xutility +++ b/stl/inc/xutility @@ -3246,11 +3246,14 @@ _NODISCARD constexpr const tuple_element_t<_Index, tuple<_Types...>>&& get(const namespace ranges { // clang-format off + template + concept _Uses_nonqualification_pointer_conversion = + is_pointer_v<_From> && is_pointer_v<_To> && + !convertible_to(*)[], remove_pointer_t<_To>(*)[]>; + template concept _Convertible_to_non_slicing = convertible_to<_From, _To> - && !(is_pointer_v> - && is_pointer_v> - && _Not_same_as>, remove_pointer_t>>); + && !_Uses_nonqualification_pointer_conversion, decay_t<_To>>; template concept _Pair_like = !is_reference_v<_Ty> && requires(_Ty __t) { diff --git a/tests/std/tests/P0896R4_ranges_subrange/test.compile.pass.cpp b/tests/std/tests/P0896R4_ranges_subrange/test.compile.pass.cpp index 66a2c6b0656..d5a1ce7b414 100644 --- a/tests/std/tests/P0896R4_ranges_subrange/test.compile.pass.cpp +++ b/tests/std/tests/P0896R4_ranges_subrange/test.compile.pass.cpp @@ -23,6 +23,12 @@ using std::output_iterator_tag, std::input_iterator_tag, std::forward_iterator_t int main() {} // COMPILE-ONLY +void test_LWG_3470() { + int a[3] = {1, 2, 3}; + int* b[3] = {&a[2], &a[0], &a[1]}; + [[maybe_unused]] auto c = std::ranges::subrange(b); +} + struct empty {}; namespace test_view_interface { From 76d0087694a528b88c811c3783630df7147f5f62 Mon Sep 17 00:00:00 2001 From: Igor Zhukov Date: Mon, 13 Dec 2021 20:54:32 +0700 Subject: [PATCH 2/3] infer size of arrays Co-authored-by: Michael Schellenberger Costa --- tests/std/tests/P0896R4_ranges_subrange/test.compile.pass.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/std/tests/P0896R4_ranges_subrange/test.compile.pass.cpp b/tests/std/tests/P0896R4_ranges_subrange/test.compile.pass.cpp index d5a1ce7b414..be0cbaa1d7b 100644 --- a/tests/std/tests/P0896R4_ranges_subrange/test.compile.pass.cpp +++ b/tests/std/tests/P0896R4_ranges_subrange/test.compile.pass.cpp @@ -24,8 +24,8 @@ using std::output_iterator_tag, std::input_iterator_tag, std::forward_iterator_t int main() {} // COMPILE-ONLY void test_LWG_3470() { - int a[3] = {1, 2, 3}; - int* b[3] = {&a[2], &a[0], &a[1]}; + int a[] = {1, 2, 3}; + int* b[] = {&a[2], &a[0], &a[1]}; [[maybe_unused]] auto c = std::ranges::subrange(b); } From 9ebf855fa1e96dbd1320da2e375ed1766c2b9a3c Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Mon, 13 Dec 2021 22:33:46 -0800 Subject: [PATCH 3/3] Style nitpicks. --- stl/inc/xutility | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/stl/inc/xutility b/stl/inc/xutility index 6d917b6a19d..a8f41b14b5f 100644 --- a/stl/inc/xutility +++ b/stl/inc/xutility @@ -3246,10 +3246,10 @@ _NODISCARD constexpr const tuple_element_t<_Index, tuple<_Types...>>&& get(const namespace ranges { // clang-format off - template + template concept _Uses_nonqualification_pointer_conversion = - is_pointer_v<_From> && is_pointer_v<_To> && - !convertible_to(*)[], remove_pointer_t<_To>(*)[]>; + is_pointer_v<_From> && is_pointer_v<_To> + && !convertible_to(*)[], remove_pointer_t<_To>(*)[]>; template concept _Convertible_to_non_slicing = convertible_to<_From, _To>