+ 2
Why no change in emplace_back and push_back
Hi Trying to store string into vector. Tried two ways 1. Push_back and 2.emplace_back I could observe two allocations on heap for both approaches. Should emplace be more efficient than push here also ? Or am i missing something ? https://code.sololearn.com/cguwgpsC94LG/?ref=app
1 Réponse
+ 4
Ketan Lalcheta maybe this might be helpful .. I would say emplace_back would be your best approach given this code however there may be times whereas yes push_back would qualify .. It really depends on what you intend to do.
https://stackoverflow.com/questions/4303513/push-back-vs-emplace-back