From: Patrick Palka Date: Tue, 19 Oct 2021 22:07:05 +0000 (-0400) Subject: libstdc++: Implement LWG 3470 change to ranges::subrange X-Git-Tag: basepoints/gcc-13~3794 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=98af6b86bc6cac705474c14bb3f9748f6866c859;p=thirdparty%2Fgcc.git libstdc++: Implement LWG 3470 change to ranges::subrange libstdc++-v3/ChangeLog: * include/bits/ranges_util.h (__detail::__uses_nonqualification_pointer_conversion): Define and use it ... (__detail::__convertible_to_nonslicing): ... here, as per LWG 3470. * testsuite/std/ranges/subrange/1.cc: New test. --- diff --git a/libstdc++-v3/include/bits/ranges_util.h b/libstdc++-v3/include/bits/ranges_util.h index aaa7e8c6a9b6..a52b8fc8f549 100644 --- a/libstdc++-v3/include/bits/ranges_util.h +++ b/libstdc++-v3/include/bits/ranges_util.h @@ -184,11 +184,16 @@ namespace ranges namespace __detail { - template + 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> - && __different_from>, - remove_pointer_t>>); + && !__uses_nonqualification_pointer_conversion, + decay_t<_To>>; template concept __pair_like diff --git a/libstdc++-v3/testsuite/std/ranges/subrange/1.cc b/libstdc++-v3/testsuite/std/ranges/subrange/1.cc new file mode 100644 index 000000000000..8a53261c78c1 --- /dev/null +++ b/libstdc++-v3/testsuite/std/ranges/subrange/1.cc @@ -0,0 +1,19 @@ +// { dg-options "-std=gnu++20" } +// { dg-do run { target c++20 } } + +#include + +void +test01() +{ + // LWG 3470 + int a[3] = {1,2,3}; + int* b[3] = {&a[2], &a[0], &a[1]}; + auto c = std::ranges::subrange(b); +} + +int +main() +{ + test01(); +}