libstdc++: Make pmr::memory_resource::allocate implicitly create objects
Calling the placement version of ::operator new "implicitly creates objects in the returned region of storage" as per [intro.object]. This allows the returned memory to be used as storage for implicit-lifetime types (including arrays) without additional action by the caller. This is required by the proposed resolution of LWG 3147. libstdc++-v3/ChangeLog: * include/std/memory_resource (memory_resource::allocate): Implicitly create objects in the returned storage.
This commit is contained in:
parent
ef0e100f58
commit
083fd73202
1 changed files with 2 additions and 1 deletions
|
@ -33,6 +33,7 @@
|
|||
|
||||
#if __cplusplus >= 201703L
|
||||
|
||||
#include <new>
|
||||
#include <vector> // vector
|
||||
#include <cstddef> // size_t, max_align_t, byte
|
||||
#include <shared_mutex> // shared_mutex
|
||||
|
@ -103,7 +104,7 @@ namespace pmr
|
|||
void*
|
||||
allocate(size_t __bytes, size_t __alignment = _S_max_align)
|
||||
__attribute__((__returns_nonnull__,__alloc_size__(2),__alloc_align__(3)))
|
||||
{ return do_allocate(__bytes, __alignment); }
|
||||
{ return ::operator new(__bytes, do_allocate(__bytes, __alignment)); }
|
||||
|
||||
void
|
||||
deallocate(void* __p, size_t __bytes, size_t __alignment = _S_max_align)
|
||||
|
|
Loading…
Add table
Reference in a new issue