libstdc++: uninitialized_construct_using_allocator should use construct_at (LWG 3321)
authorJonathan Wakely <jwakely@redhat.com>
Wed, 19 Feb 2020 12:14:54 +0000 (12:14 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Wed, 19 Feb 2020 12:46:57 +0000 (12:46 +0000)
* include/std/memory (uninitialized_construct_using_allocator): Use
std::construct_at (LWG 3321).

libstdc++-v3/ChangeLog
libstdc++-v3/include/std/memory

index eb83c632adc08d9a3e3ea4664cb25cc937639f54..5408a89c7fbd324f5cc0e0e047a89564544c7d94 100644 (file)
@@ -1,5 +1,8 @@
 2020-02-19  Jonathan Wakely  <jwakely@redhat.com>
 
+       * include/std/memory (uninitialized_construct_using_allocator): Use
+       std::construct_at (LWG 3321).
+
        * include/std/memory_resource (polymorphic_allocator::allocate_bytes)
        (polymorphic_allocator::allocate_object)
        (polymorphic_allocator::new_object): Add nodiscard attribute (LWG3304).
index 14aedb70dacda09172da39c70db62f5bcbbeb9f0..aaee6e42c1a1470162f9cd48ddefd2b651bd9b6d 100644 (file)
@@ -387,9 +387,10 @@ get_pointer_safety() noexcept { return pointer_safety::relaxed; }
     uninitialized_construct_using_allocator(_Tp* __p, const _Alloc& __a,
                                            _Args&&... __args)
     {
-      void* __vp = const_cast<void*>(static_cast<const volatile void*>(__p));
-      return ::new(__vp) _Tp(std::make_obj_using_allocator<_Tp>(__a,
-           std::forward<_Args>(__args)...));
+      return std::apply([&](auto&&... __xs) {
+       return std::construct_at(__p, std::forward<decltype(__xs)>(__xs)...);
+      }, std::uses_allocator_construction_args<_Tp>(__a,
+       std::forward<_Args>(__args)...));
     }
 // @}