1 #ifndef DEFAULT_INIT_ALLOCATOR_DOT_HPP
2 #define DEFAULT_INIT_ALLOCATOR_DOT_HPP
4 // Allocator adaptor that interposes construct() calls to convert
5 // value initialization into default initialization.
7 // <https://en.cppreference.com/w/cpp/container/vector/resize>
8 // <https://stackoverflow.com/a/21028912/273767>
12 template <typename T
, typename A
= std::allocator
<T
>>
13 class default_init_allocator
: public A
{
14 typedef std::allocator_traits
<A
> a_t
;
20 = default_init_allocator
<U
, typename
a_t::template rebind_alloc
<U
>>;
27 construct(U
* ptr
) noexcept(std::is_nothrow_default_constructible
<U
>::value
)
29 ::new (static_cast<void*>(ptr
)) U
;
31 template <typename U
, typename
... Args
>
32 void construct(U
* ptr
, Args
&&... args
)
34 a_t::construct(static_cast<A
&>(*this), ptr
, std::forward
<Args
>(args
)...);
38 #endif // DEFAULT_INIT_ALLOCATOR_DOT_HPP