Does std :: list indicate that items will never be moved to another memory location?

Is it guaranteed that after the selection of the element, std::listor std::forward_listit will remain in the same place (address) of the memory until it is destroyed? Except, of course, for copying the list itself.

+4
source share
1 answer

If you look at the documentation for all functions that do not destroy elements ( insert , emplace , push_back , etc.), you will see that they have a note that “links are not invalid”, which is equivalent to what you ask for (objects located in the same memory location). So yes.

+7
source

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


All Articles