// From: http://stackoverflow.com/questions/21028299/is-this-behavior-of-vectorresizesize-type-n-under-c11-and-boost-container // Credits: Casey and Howard Hinnant #ifndef DEFAULT_INIT_ALLOCATOR_H_ #define DEFAULT_INIT_ALLOCATOR_H_ #include namespace cs { // Allocator adaptor that interposes construct() calls to // convert value initialization into default initialization. template > class default_init_allocator : public A { typedef std::allocator_traits a_t; public: template struct rebind { using other = default_init_allocator>; }; using A::A; template void construct(U* ptr) noexcept( std::is_nothrow_default_constructible::value) { ::new (static_cast(ptr)) U; } template void construct(U* ptr, Args&&... args) { a_t::construct(static_cast(*this), ptr, std::forward(args)...); } }; } // namespace cs #endif // DEFAULT_INIT_ALLOCATOR_H_