Why doesn’t emplace_back() use uniform initialization?

Great minds think alike ;v) . I submitted a defect report and suggested a change to the standard on this very topic. http://cplusplus.github.com/LWG/lwg-active.html#2089 Also, Luc Danton helped me understand the difficulty: Direct vs uniform initialization in std::allocator. When the EmplaceConstructible (23.2.1 [container.requirements.general]/13) requirement is used to initialize an object, direct-initialization occurs. Initializing an aggregate or … Read more

Why does ‘std::vector b{2};’ create a 1-element vector, and not a 2-element one?

Yes, this behaviour is intended, according to §13.3.1.7 Initialization by list-initialization When objects of non-aggregate class type T are list-initialized (8.5.4), overload resolution selects the constructor in two phases: — Initially, the candidate functions are the initializer-list constructors (8.5.4) of the class T and the argument list consists of the initializer list as a single … Read more

tech