Answer the question
In order to leave comments, you need to log in
Why did C++11 have 1 push_back overload and emplace_back method, because you could use a universal reference?
Why didn’t C++ just replace the push_back signature from vector::push_back(const T&) with template vector::push_back(Args&& ...) (well, just use forward inside this push back), but instead add a vector overload: :push_back( T&&) and emplace_back method?
I can't figure out where replacing push_back's signature with vector::push_back(Args&& ...) breaks backwards compatibility
Answer the question
In order to leave comments, you need to log in
emplace_back does not place the passed object into the vector, but creates a new object right inside the vector. emplace_back takes the parameters of the constructor of the object being created as arguments.
I re-read the question again and realized that I was not answering that.
Regarding the two versions of push_back, Howard Hinnant (a member of the C++ standards committee) replied that it was easier to add a new feature than to change an existing one.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question