Std :: map: can it copy and move keys after they are installed?

In other words, is it safe to store pointers to keys from a map? Or is it possible for a card to copy and move keys throughout its life, thereby invalidating existing pointers?

The docs say, "Iterator Validity: No Change." Does this mean that the answer to my question is "no, they cannot be copied or moved"?

+5
source share
1 answer

The std::map container std::map provides a node container, which means that iterators and references to the container element never become invalid until the element is removed from the map. Thus, you can transfer the keyword addresses of the element to third parties while the map is alive and the element remains inside it.

+7
source

Source: https://habr.com/ru/post/1243528/


All Articles