public inbox for libstdc++-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 r14-6357] libstdc++: Fix resolution of LWG 4016 for std::ranges::to [PR112876] Date: Sat, 9 Dec 2023 14:06:50 +0000 (GMT) [thread overview] Message-ID: <20231209140650.6FD033858006@sourceware.org> (raw) https://gcc.gnu.org/g:a314edee2490259d7f7caec8eef77846bcdb608b commit r14-6357-ga314edee2490259d7f7caec8eef77846bcdb608b Author: Jonathan Wakely <jwakely@redhat.com> Date: Fri Dec 8 13:47:04 2023 +0000 libstdc++: Fix resolution of LWG 4016 for std::ranges::to [PR112876] What I implemented in r14-6199-g45630fbcf7875b does not match what I proposed for LWG 4016, and it imposes additional, unwanted requirements on the emplace and insert member functions of the container being populated. libstdc++-v3/ChangeLog: PR libstdc++/112876 * include/std/ranges (ranges::to): Do not try to use an iterator returned by the container's emplace or insert member functions. * testsuite/std/ranges/conv/1.cc (Cont4::emplace, Cont4::insert): Use the iterator parameter. Do not return an iterator. Diff: --- libstdc++-v3/include/std/ranges | 10 +++------- libstdc++-v3/testsuite/std/ranges/conv/1.cc | 12 ++++++------ 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges index fb9df3d3e79..be8475c0cb1 100644 --- a/libstdc++-v3/include/std/ranges +++ b/libstdc++-v3/include/std/ranges @@ -9300,14 +9300,10 @@ namespace __detail __c.emplace_back(*__it); else if constexpr (requires { __c.push_back(*__it); }) __c.push_back(*__it); + else if constexpr (requires { __c.emplace(__c.end(), *__it); }) + __c.emplace(__c.end(), *__it); else - { - auto __end = __c.end(); - if constexpr (requires { __c.emplace(__end, *__it); }) - __end = __c.emplace(__end, *__it); - else - __end = __c.insert(__end, *__it); - } + __c.insert(__c.end(), *__it); ++__it; } return __c; diff --git a/libstdc++-v3/testsuite/std/ranges/conv/1.cc b/libstdc++-v3/testsuite/std/ranges/conv/1.cc index b5f861dedb3..6d6a708ab64 100644 --- a/libstdc++-v3/testsuite/std/ranges/conv/1.cc +++ b/libstdc++-v3/testsuite/std/ranges/conv/1.cc @@ -236,19 +236,19 @@ struct Cont4 template<typename T> requires (Kind <= Emplace) && requires(C& c, T&& t) { c.emplace(c.end(), std::forward<T>(t)); } - typename C::iterator - emplace(typename C::iterator, T&& t) + void + emplace(typename C::iterator pos, T&& t) { kind = Emplace; - return c.emplace(c.end(), std::forward<T>(t)); + c.emplace(pos, std::forward<T>(t)); } template<typename T> - typename C::iterator - insert(typename C::iterator, T&& t) + void + insert(typename C::iterator pos, T&& t) { kind = Insert; - return c.insert(c.end(), std::forward<T>(t)); + c.insert(pos, std::forward<T>(t)); } // Required to satisfy reservable-container
reply other threads:[~2023-12-09 14:06 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=20231209140650.6FD033858006@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).