public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Jonathan Wakely <redi@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r12-6483] libstdc++: Make copyable-box completely constexpr (LWG 3572) Date: Tue, 11 Jan 2022 15:17:37 +0000 (GMT) [thread overview] Message-ID: <20220111151737.4ADB93858D39@sourceware.org> (raw) https://gcc.gnu.org/g:d2dc5305d87f4e6a1b861f59164c124636e2b69d commit r12-6483-gd2dc5305d87f4e6a1b861f59164c124636e2b69d Author: Jonathan Wakely <jwakely@redhat.com> Date: Tue Jan 11 14:11:46 2022 +0000 libstdc++: Make copyable-box completely constexpr (LWG 3572) This LWG issue was approved at the October 2021 plenary and can be implemented now that std::optional is fully constexpr. libstdc++-v3/ChangeLog: * include/std/ranges (ranges::__detail::__box): Add constexpr to assignment operators (LWG 3572). * testsuite/std/ranges/adaptors/filter.cc: Check assignment of a view that uses copyable-box. Diff: --- libstdc++-v3/include/std/ranges | 5 ++-- .../testsuite/std/ranges/adaptors/filter.cc | 28 ++++++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges index c90d33c89fb..780a3633417 100644 --- a/libstdc++-v3/include/std/ranges +++ b/libstdc++-v3/include/std/ranges @@ -109,7 +109,8 @@ namespace ranges // _GLIBCXX_RESOLVE_LIB_DEFECTS // 3477. Simplify constraints for semiregular-box - __box& + // 3572. copyable-box should be fully constexpr + constexpr __box& operator=(const __box& __that) noexcept(is_nothrow_copy_constructible_v<_Tp>) requires (!copyable<_Tp>) @@ -124,7 +125,7 @@ namespace ranges return *this; } - __box& + constexpr __box& operator=(__box&& __that) noexcept(is_nothrow_move_constructible_v<_Tp>) requires (!movable<_Tp>) diff --git a/libstdc++-v3/testsuite/std/ranges/adaptors/filter.cc b/libstdc++-v3/testsuite/std/ranges/adaptors/filter.cc index b8d081e1d5e..ed5a01ca595 100644 --- a/libstdc++-v3/testsuite/std/ranges/adaptors/filter.cc +++ b/libstdc++-v3/testsuite/std/ranges/adaptors/filter.cc @@ -140,6 +140,33 @@ test06() static_assert(!requires { views::all | filter; }); } +constexpr bool +test07() +{ + struct Pred + { + constexpr Pred() { } + constexpr Pred(const Pred&) { } + constexpr Pred(Pred&&) { } + // These make it non-copyable, so non-copyable-box<Pred> will provide + // assignment. + Pred& operator=(const Pred&) = delete; + Pred& operator=(Pred&&) = delete; + + bool operator()(int i) const { return i < 10; } + }; + + int i = 0; + ranges::filter_view v(views::single(i), Pred{}); + // LWG 3572. copyable-box should be fully constexpr + v = v; + v = std::move(v); + + return true; +} + +static_assert( test07() ); + int main() { @@ -150,4 +177,5 @@ main() test05<forward_iterator_wrapper>(); test05<random_access_iterator_wrapper>(); test06(); + test07(); }
reply other threads:[~2022-01-11 15:17 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=20220111151737.4ADB93858D39@sourceware.org \ --to=redi@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).