public inbox for libstdc++-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 r11-9818] libstdc++: Implement LWG 3481 change to ranges::viewable_range Date: Tue, 12 Apr 2022 14:28:43 +0000 (GMT) [thread overview] Message-ID: <20220412142843.51745385840C@sourceware.org> (raw) https://gcc.gnu.org/g:60b4a814777456527b48f77ef1d0a6af26a83242 commit r11-9818-g60b4a814777456527b48f77ef1d0a6af26a83242 Author: Patrick Palka <ppalka@redhat.com> Date: Wed Oct 20 21:34:18 2021 -0400 libstdc++: Implement LWG 3481 change to ranges::viewable_range libstdc++-v3/ChangeLog: * include/bits/ranges_base.h (viewable_range): Adjust as per LWG 3481. * testsuite/std/ranges/adaptors/all.cc (test07): New test. (cherry picked from commit a2c2dcc6ca205a8c5c76b04ef2eb4fb097dcb069) Diff: --- libstdc++-v3/include/bits/ranges_base.h | 3 ++- libstdc++-v3/testsuite/std/ranges/adaptors/all.cc | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/libstdc++-v3/include/bits/ranges_base.h b/libstdc++-v3/include/bits/ranges_base.h index 48a9d0d95bb..87283b84028 100644 --- a/libstdc++-v3/include/bits/ranges_base.h +++ b/libstdc++-v3/include/bits/ranges_base.h @@ -664,7 +664,8 @@ namespace ranges /// A range which can be safely converted to a view. template<typename _Tp> concept viewable_range = range<_Tp> - && (borrowed_range<_Tp> || view<remove_cvref_t<_Tp>>); + && ((view<remove_cvref_t<_Tp>> && constructible_from<remove_cvref_t<_Tp>, _Tp>) + || (!view<remove_cvref_t<_Tp>> && borrowed_range<_Tp>)); // [range.iter.ops] range iterator operations diff --git a/libstdc++-v3/testsuite/std/ranges/adaptors/all.cc b/libstdc++-v3/testsuite/std/ranges/adaptors/all.cc index 42913ad38a3..5facaee7b37 100644 --- a/libstdc++-v3/testsuite/std/ranges/adaptors/all.cc +++ b/libstdc++-v3/testsuite/std/ranges/adaptors/all.cc @@ -130,6 +130,20 @@ test05() static_assert(!requires { 0 | all; }); } +void +test07() +{ + // LWG 3481 + struct view_t : ranges::empty_view<int> { // move-only view + view_t(const view_t&) = delete; + view_t(view_t&&) = default; + view_t& operator=(const view_t&) = delete; + view_t& operator=(view_t&&) = default; + }; + static_assert(std::movable<view_t> && !std::copyable<view_t>); + static_assert(!ranges::viewable_range<view_t&>); +} + int main() { @@ -138,4 +152,5 @@ main() static_assert(test03()); static_assert(test04()); test05(); + test07(); }
reply other threads:[~2022-04-12 14:28 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=20220412142843.51745385840C@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).