This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++20 status.

3321. uninitialized_construct_using_allocator should use construct_at

Section: [] Status: C++20 Submitter: United States Opened: 2019-11-06 Last modified: 2021-02-25

Priority: 0

View all other issues in [].

View all issues with C++20 status.


Addresses US 213

uninitialized_construct_using_allocator should use construct_at instead of operator new

Proposed change:

Effects: Equivalent to:

return ::new(static_cast<void*>(p))

Tim Song:

The proposed wording in the NB comment is incorrect, because it prevents guaranteed elision.

[2019-11 Status to Ready during Wednesday night issue processing in Belfast.]

Proposed resolution:

This wording is relative to N4835.

  1. Modify [] as indicated:

    template<class T, class Alloc, class... Args>
      constexpr T* uninitialized_construct_using_allocator(T* p, const Alloc& alloc, Args&&... args);

    -17- Effects: Equivalent to:

    return ::new(static_cast<void*>(p))
      T(make_obj_using_allocator<T>(apply([&](auto&&...xs) {
             return construct_at(p, std::forward<decltype(xs)>(xs)...);
         }, uses_allocator_construction_args<T>(alloc, std::forward<Args>(args)...));