We all know that addresses of elements in vector<T>
may change when we append more elements (due to resizing), while elements in list<T>
remains at the same address.
The question is, what about vector<list<T>>
? For example,
vector<list<T>> container;
// Insert some elements to container...
T* ptr = &(container[0].back());
// Insert more elements to container...
Can we assume that ptr
stays valid?
Naively, I think it should, because when the vector resizes it should call the move constructor of list<T>
, which should not copy/move individual elements. However, I don't know if the standard ensures this.