Is it safe to assume that any pointers I have to elements inside of an std::deque
are still valid after moving the deque to another one with the move constructor?
For std::vector
I cannot see any reason why they wouldn't be, but I'm not familiar enough with std::deque
to be sure I can make the same assumption.
CodePudding user response:
Pointers to elements would remain valid. After move construction:
After container move construction (overload (8)), references, pointers, and iterators (other than the end iterator) to other remain valid, but refer to elements that are now in
*this
. The current standard makes this guarantee via the blanket statement in [container.requirements.general]/12, and a more direct guarantee is under consideration via LWG 2321.