Hacker News new | ask | show | jobs
by tummulfingur 1933 days ago
>> or some other piece of code is known to keep direct references to the elements that should not be invalidated

> In that case, why not store the elements in a unique_ptr (and then everything in a vector)?

I recently ended up using std::list<Object*> because of pointer invalidation on vector resize. I see now that using smart pointers would have worked just as well. Thanks.