|
|
std::list
, this is safe. It does not reallocate the elements when you add or remove more elements in the container. But in general this is dangerous as container elements may change its location in the memory.23.2.2.3 list modifiers [lib.list.modifiers] iterator insert(iterator position, const T& x); void insert(iterator position, size_type n, const T& x); template <class InputIterator> void insert(iterator position, InputIterator first, InputIterator last); void push_front(const T& x); void push_back(const T& x); 1 Notes: Does not affect the validity of iterators and references. If an exception is thrown there are no effects. ... iterator erase(iterator position); iterator erase(iterator first, iterator last); void pop_front(); void pop_back(); void clear(); 3 Effects: Invalidates only the iterators and references to the erased elements. |