简体   繁体   中英

Are references / pointers guaranteed to be valid after moving std::deque?

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.

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM