Defined in header
template < class T, class... Args >
void construct( T* p, Args&&... args );
template< class T1, class T2 >
void construct( std::pair<T1, T2>* p );
template< class T1, class T2, class U, class V >
void construct( std::pair<T1, T2>* p, U&& x, V&& y );
Constructs an object in allocated, but not initialized storage pointed to by
p using OuterAllocator and the provided constructor arguments. If the object is of type that itself uses allocators, or if it is std::pair, passes InnerAllocator down to the constructed object.
First, retrieve the outermost allocator
OUTERMOST by calling this->outer_allocator(), and then calling the
outer_allocator() member function recursively on the result of this call until reaching an allocator that has no such member function.
Tby means of uses-allocator construction at the uninitialized memory location indicated by p, using OUTERMOST as the allocator. After adjustment for uses-allocator convention expected by T's constructor, calls OUTERMOST_ALLOC_TRAITS(*this)::construct.
This overload only participates in overload resolution if
2) First, if either
Same rules apply to
3) Equivalent to construct(p, std::piecewise_construct, std::tuple<>(), std::tuple<>()), that is, passes the inner allocator on to the pair's member types if they accept them.
4) Equivalent to
5) Equivalent to
|p||-||pointer to allocated, but not initialized storage|
|args...||-|| the constructor arguments to pass to the constructor of |
|x||-|| the constructor arguments to pass to the constructor of |
|y||-|| the constructor arguments to pass to the constructor of |
|xy||-|| the pair whose two members are the constructor arguments for |
 Return value
This function is called (through std::allocator_traits) by any allocator-aware object, such as std::vector, that was given a std::scoped_allocator_adaptor as the allocator to use. Since
inner_allocator is itself an instance of std::scoped_allocator_adaptor, this function will also be called when the allocator-aware objects constructed through this function start constructing their own members.
 Defect reports
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
|DR||Applied to||Behavior as published||Correct behavior|
|LWG 2975||C++11||first overload is mistakenly used for pair construction in some cases||constrained to not accept pairs|
|P0475R1||C++11||pair piecewise construction may copy the arguments||transformed to tuples of references to avoid copy|
 See also
| constructs an object in the allocated storage |
(deprecated in C++17)(removed in C++20)
| constructs an object in allocated storage |
(public member function of