From: Jonathan Wakely <jwakely@redhat.com>
To: Patrick Palka <ppalka@redhat.com>
Cc: gcc Patches <gcc-patches@gcc.gnu.org>,
"libstdc++" <libstdc++@gcc.gnu.org>
Subject: Re: [PATCH] libstdc++: Implement LWG 3481 change to ranges::viewable_range
Date: Wed, 20 Oct 2021 19:55:40 +0100 [thread overview]
Message-ID: <CACb0b4me2nm56trvi9P=khYWadVg94PmkhUHhEVBuyxYjLTgcg@mail.gmail.com> (raw)
In-Reply-To: <20211020165927.1827031-1-ppalka@redhat.com>
On Wed, 20 Oct 2021 at 18:01, Patrick Palka wrote:
>
> Tested on x86_64-pc-linux-gnu, does this look OK for trunk, and branches
> after a while?
Yes for all.
>
> libstdc++-v3/ChangeLog:
>
> * include/bits/ranges_base.h (viewable_range): Adjust as per
> LWG 3481.
> * testsuite/std/ranges/adaptors/all.cc (test07): New test.
> ---
> 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 7801b2fd023..43b0b9f7bf3 100644
> --- a/libstdc++-v3/include/bits/ranges_base.h
> +++ b/libstdc++-v3/include/bits/ranges_base.h
> @@ -688,7 +688,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 9a6a31e6cb4..ce1384c2890 100644
> --- a/libstdc++-v3/testsuite/std/ranges/adaptors/all.cc
> +++ b/libstdc++-v3/testsuite/std/ranges/adaptors/all.cc
> @@ -159,6 +159,20 @@ test06()
> static_assert(!noexcept(views::all(BorrowedRange<false, false>(x))));
> }
>
> +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()
> {
> @@ -168,4 +182,5 @@ main()
> static_assert(test04());
> test05();
> test06();
> + test07();
> }
> --
> 2.33.1.711.g9d530dc002
>
prev parent reply other threads:[~2021-10-20 18:55 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-20 16:59 Patrick Palka
2021-10-20 18:55 ` Jonathan Wakely [this message]
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='CACb0b4me2nm56trvi9P=khYWadVg94PmkhUHhEVBuyxYjLTgcg@mail.gmail.com' \
--to=jwakely@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=libstdc++@gcc.gnu.org \
--cc=ppalka@redhat.com \
/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: link
Be 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).