Should allocator construct() default initialize instead of value initializing?
问题 As a followup to this question, the default allocator ( std::allocator<T> ) is required to implement construct as follows (according to [default.allocator]): template <class U, class... Args> void construct(U* p, Args&&... args); Effects : ::new((void *)p) U(std::forward<Args>(args)...) That is, always value-initialization. The result of this is that std::vector<POD> v(num) , for any pod type, will value-initialize num elements - which is more expensive than default-initializing num elements.