I\'m a bit confused regarding the difference between push_back
and emplace_back
.
void emplace_back(Type&& _Val);
void push_
emplace_back
conforming implementation will forward arguments to the vector
constructor when added to the vector. I recall Visual Studio didn't support variadic templates, but with variadic templates will be supported in Visual Studio 2013 RC, so I guess a conforming signature will be added.
With emplace_back
, if you forward the arguments directly to vector
constructor, you don't need a type to be movable or copyable for emplace_back
function, strictly speaking. In the vector
case, this is not useful, since vector
needs a copyable or movable type to grow.
But note that this could be useful for std::map
, since once you allocate an entry in the map, it doesn't need to be moved or copied ever anymore, unlike with vector
, meaning that you can use std::map
effectively with a mapped type that is neither copyable nor movable.