3321. uninitialized_construct_using_allocator should use construct_at

Section: [allocator.uses.construction] Status: C++20 Submitter: United States Opened: 2019-11-06 Last modified: 2021-02-25 10:48:01 UTC

Priority: 0

View all other issues in [allocator.uses.construction].

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 [allocator.uses.construction] 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)...));