]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Use std::construct_at in net::ip::address
authorJonathan Wakely <jwakely@redhat.com>
Wed, 17 Nov 2021 15:05:43 +0000 (15:05 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Wed, 17 Nov 2021 17:28:52 +0000 (17:28 +0000)
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.

libstdc++-v3/include/experimental/internet

index 95b8cdc99637fb8712617056fafb1bee6c817a92..5e2ef00c16f0d9aae2cd39b6461f810df3cacb92 100644 (file)
@@ -466,9 +466,9 @@ namespace ip
     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
@@ -491,7 +491,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;
     }
@@ -499,7 +499,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;
     }