public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Patrick Palka <ppalka@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r12-4519] libstdc++: Implement LWG 3470 change to ranges::subrange Date: Tue, 19 Oct 2021 22:09:55 +0000 (GMT) [thread overview] Message-ID: <20211019220955.22C713858D39@sourceware.org> (raw) https://gcc.gnu.org/g:98af6b86bc6cac705474c14bb3f9748f6866c859 commit r12-4519-g98af6b86bc6cac705474c14bb3f9748f6866c859 Author: Patrick Palka <ppalka@redhat.com> Date: Tue Oct 19 18:07:05 2021 -0400 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: --- libstdc++-v3/include/bits/ranges_util.h | 13 +++++++++---- libstdc++-v3/testsuite/std/ranges/subrange/1.cc | 19 +++++++++++++++++++ 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/libstdc++-v3/include/bits/ranges_util.h b/libstdc++-v3/include/bits/ranges_util.h index aaa7e8c6a9b..a52b8fc8f54 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<class _From, class _To> + template<typename _From, typename _To> + concept __uses_nonqualification_pointer_conversion + = is_pointer_v<_From> && is_pointer_v<_To> + && !convertible_to<remove_pointer_t<_From>(*)[], + remove_pointer_t<_To>(*)[]>; + + template<typename _From, typename _To> concept __convertible_to_non_slicing = convertible_to<_From, _To> - && !(is_pointer_v<decay_t<_From>> && is_pointer_v<decay_t<_To>> - && __different_from<remove_pointer_t<decay_t<_From>>, - remove_pointer_t<decay_t<_To>>>); + && !__uses_nonqualification_pointer_conversion<decay_t<_From>, + decay_t<_To>>; template<typename _Tp> 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 00000000000..8a53261c78c --- /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 <ranges> + +void +test01() +{ + // LWG 3470 + int a[3] = {1,2,3}; + int* b[3] = {&a[2], &a[0], &a[1]}; + auto c = std::ranges::subrange<const int*const*>(b); +} + +int +main() +{ + test01(); +}
reply other threads:[~2021-10-19 22:09 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20211019220955.22C713858D39@sourceware.org \ --to=ppalka@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ --cc=libstdc++-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).