4 ms·
emplacement doesn't handle lifetime management; the vector itself does this, whether you emplace or push. push_back with a stack object will copy the object, y
by hellofunk 10y ago
emplacement doesn't handle lifetime management; the vector itself does this, whether you emplace or push.
push_back with a stack object will copy the object, yes. Emplace_back with a stack object will also, they are not much different. But if you emplace by creating the object inside the emplace call itself, then there is no copy.
see the examples here:
http://en.cppreference.com/w/cpp/container/vector/emplace_back http://en.cppreference.com/w/cpp/container/vector/emplace_ba...
- Cyph0n 10y agoThat makes sense. Thanks for the help man, and sorry if I bothered you!