Currently using C++20, G++11.1.0.
What is the best way to add new elements to a vector of unique pointers?
I'm currently using vec.emplace_back(new Object)
, which works well for me. In some instances, just doing vec.emplace_back()
works as well (not sure if its supposed to though).
After reading through this thread, I'm not sure what the best or safest method is. Should I even be using emplace_back
? Or should I be using push_back
instead?