0

What is difference between vector push_back insert and emplace function in cpp?

3rd Jun 2020, 4:32 PM
Rushikesh Kate
Rushikesh Kate - avatar
3 Antworten
3rd Jun 2020, 5:59 PM
Bobby Fischer
Bobby Fischer - avatar
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.
3rd Jun 2020, 4:56 PM
Bobby Fischer
Bobby Fischer - avatar