The c++17 specification deprecates the
Because this function provides the automatic fall back to placement new, the member function construct() is an optional Allocator requirement since C++11.
The mandated behavior of member
construct is (between C++11 - C++17):
Effect: Constructs an object of type
This means that the function is effectively required to invoke placement
new with forwarded arguments at some point; the only permitted divergence in behavior for a user-supplied allocator is to perform some other action before and/or after, such as instrumentation; it is not permitted to alter the arguments to placement
new in any way.
As such and since
allocator_traits::construct performs the requisite placement
new anyway, user code e.g. in containers is likely to just perform placement
new directly, so the whole machinery of
construct is redundant.
In a custom allocator (e.g. for page-aligned memory using
memalign), falling back to placement
newprobably would not be the correct behavior.
In such an allocator the address
c should already be aligned correctly, since it was obtained from the allocator. The allocator has no choice but to perform placement