0
What is difference between vector push_back insert and emplace function in cpp?
3 Respuestas
+ 2
AMOGHA. A. K.
Hi Pete Becker! :-)
https://stackoverflow.com/a/15659336
0
suppose you have a vector of pairs:
vector<pair<int, int>> v
you want to insert something.
v.push_back({a, b});
v.emplace_back(a, b);
will yield the same results.
emplace_back saves you from copying the object, so you just need to pass the arguments.