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 r11-10164] libstdc++: Use std::construct_at in std::common_iterator [PR103992] Date: Fri, 22 Jul 2022 07:07:51 +0000 (GMT) [thread overview] Message-ID: <20220722070751.12D853834E5F@sourceware.org> (raw) https://gcc.gnu.org/g:64beecc2201a1da216a8d3feca85974e08e3c890 commit r11-10164-g64beecc2201a1da216a8d3feca85974e08e3c890 Author: Jonathan Wakely <jwakely@redhat.com> Date: Wed Jan 12 16:58:18 2022 +0000 libstdc++: Use std::construct_at in std::common_iterator [PR103992] This should have been done as part of the LWG 3574 changes. libstdc++-v3/ChangeLog: PR libstdc++/103992 * include/bits/stl_iterator.h (common_iterator): Use std::construct_at instead of placement new. * testsuite/24_iterators/common_iterator/1.cc: Check copy construction is usable in constant expressions. (cherry picked from commit d67ba1dce9796bff177e52e2bbb68bfa2c69a884) Diff: --- libstdc++-v3/include/bits/stl_iterator.h | 8 ++++---- libstdc++-v3/testsuite/24_iterators/common_iterator/1.cc | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/libstdc++-v3/include/bits/stl_iterator.h b/libstdc++-v3/include/bits/stl_iterator.h index 96ca48e8130..522da18ea1f 100644 --- a/libstdc++-v3/include/bits/stl_iterator.h +++ b/libstdc++-v3/include/bits/stl_iterator.h @@ -1808,14 +1808,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION if constexpr (is_trivially_default_constructible_v<_It>) _M_it = std::move(__x._M_it); else - ::new((void*)std::__addressof(_M_it)) _It(__x._M_it); + std::construct_at(std::__addressof(_M_it), __x._M_it); } else if (_M_index == 1) { if constexpr (is_trivially_default_constructible_v<_Sent>) _M_sent = std::move(__x._M_sent); else - ::new((void*)std::__addressof(_M_sent)) _Sent(__x._M_sent); + std::construct_at(std::__addressof(_M_sent), __x._M_sent); } } @@ -1829,14 +1829,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION if constexpr (is_trivially_default_constructible_v<_It>) _M_it = std::move(__x._M_it); else - ::new((void*)std::__addressof(_M_it)) _It(__x._M_it); + std::construct_at(std::__addressof(_M_it), __x._M_it); } else if (_M_index == 1) { if constexpr (is_trivially_default_constructible_v<_Sent>) _M_sent = std::move(__x._M_sent); else - ::new((void*)std::__addressof(_M_sent)) _Sent(__x._M_sent); + std::construct_at(std::__addressof(_M_sent), __x._M_sent); } } diff --git a/libstdc++-v3/testsuite/24_iterators/common_iterator/1.cc b/libstdc++-v3/testsuite/24_iterators/common_iterator/1.cc index db38230f323..db371c68f02 100644 --- a/libstdc++-v3/testsuite/24_iterators/common_iterator/1.cc +++ b/libstdc++-v3/testsuite/24_iterators/common_iterator/1.cc @@ -157,6 +157,22 @@ test04() VERIFY( x.i == 2 ); } +constexpr bool +test_pr103992() +{ + using C1 = std::common_iterator<std::reverse_iterator<int*>, + std::unreachable_sentinel_t>; + using C2 = std::common_iterator<std::reverse_iterator<const int*>, + std::unreachable_sentinel_t>; + C1 c1; + C2 c2 = c1; + C1 c3 = c1; + + return true; +} + +static_assert( test_pr103992() ); + int main() {
reply other threads:[~2022-07-22 7:07 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=20220722070751.12D853834E5F@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).