If I have a std::vector
of std::unique_ptr
and resize it, and wanted to add element by index, what is the best way to add them using operator=
?
std::vector<std::unique_ptr<item>> _v;
_v.resize(100);
// is it safe to use the assignment operator?
_v[20] = new item;