public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r11-9913] libstdc++: Use std::construct_at in net::ip::address
@ 2022-04-21 12:33 Jonathan Wakely
  0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2022-04-21 12:33 UTC (permalink / raw)
  To: gcc-cvs, libstdc++-cvs

https://gcc.gnu.org/g:e062a13a58a378448a7dd10ced295690f9b0d504

commit r11-9913-ge062a13a58a378448a7dd10ced295690f9b0d504
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Nov 17 15:05:43 2021 +0000

    libstdc++: Use std::construct_at in net::ip::address
    
    Using placement-new isn't valid in constant expressions, so this
    replaces it with std::construct_at (via the std::_Construct function
    that is usable before C++20).
    
    libstdc++-v3/ChangeLog:
    
            * include/experimental/internet (address): Use std::_Construct
            to initialize union members.
    
    (cherry picked from commit 5ea8803e65eb546f58d3dccf5aff94a1638ba8b2)

Diff:
---
 libstdc++-v3/include/experimental/internet | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/libstdc++-v3/include/experimental/internet b/libstdc++-v3/include/experimental/internet
index 6ce070ae775..07eb137fb80 100644
--- a/libstdc++-v3/include/experimental/internet
+++ b/libstdc++-v3/include/experimental/internet
@@ -441,13 +441,15 @@ namespace ip
     // constructors:
     constexpr address() noexcept : _M_v4(), _M_is_v4(true) { }
 
+#if __cpp_constexpr_dynamic_alloc
     constexpr
+#endif
     address(const address& __a) noexcept : _M_uninit(), _M_is_v4(__a._M_is_v4)
     {
       if (_M_is_v4)
-	::new (std::addressof(_M_v4)) address_v4(__a.to_v4());
+	std::_Construct(std::addressof(_M_v4), __a.to_v4());
       else
-	::new (std::addressof(_M_v6)) address_v6(__a.to_v6());
+	std::_Construct(std::addressof(_M_v6), __a.to_v6());
     }
 
     constexpr
@@ -470,7 +472,7 @@ namespace ip
     address&
     operator=(const address_v4& __a) noexcept
     {
-      ::new (std::addressof(_M_v4)) address_v4(__a);
+      std::_Construct(std::addressof(_M_v4), __a);
       _M_is_v4 = true;
       return *this;
     }
@@ -478,7 +480,7 @@ namespace ip
     address&
     operator=(const address_v6& __a) noexcept
     {
-      ::new (std::addressof(_M_v6)) address_v6(__a);
+      std::_Construct(std::addressof(_M_v6), __a);
       _M_is_v4 = false;
       return *this;
     }


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-04-21 12:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-21 12:33 [gcc r11-9913] libstdc++: Use std::construct_at in net::ip::address Jonathan Wakely

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).