emplace vs push c 2b 2b

Solutions on MaxInterview for emplace vs push c 2b 2b by the best coders in the world

showing results for - "emplace vs push c 2b 2b"
Aymane
11 Mar 2019
1push() adds a copy of an already constructed object into the queue as a 
2parameter, it takes an object of the queue's element type.
3
4emplace() constructs a new object in-place at the end of the queue. It takes 
5as parameters the parameters that the queue's element types constructor takes.
6
7If your usage pattern is one where you create a new object and add it to the
8container, you shortcut a few steps (creation of a temporary object and copying
9it) by using emplace().