Based on the answers in these questions here, I know that it is certainly preferred to use c++14's std::make_unique
than to emplace_back(new X)
directly.
That said, is it preferred to call
my_vector.push_back(std::make_unique<Foo>("constructor", "args"));
or
my_vector.emplace_back(std::make_unique<Foo>("constructor", "args"));
That is, should I use push_back
or emplace_back
when adding an std::unique_ptr
constructed from std::make_unique
?
==== EDIT ====
and why? c: <-- (tiny smile)