3 ms·
You want std::vector::emplace_back. I think technically you could use unique_ptr and transfer ownership (move) when pushing into the vector, but the underlying
by gcp 10y ago
You want std::vector::emplace_back.
I think technically you could use unique_ptr and transfer ownership (move) when pushing into the vector, but the underlying "bad pattern" here is that you almost never want to have a vector of (smart) pointers. The vector should own the objects directly.