Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is pointer stability?

The second paragraph in this link on Abseil containers says:

For example, the Abseil containers often do not guarantee pointer stability after insertions or deletions.

What does pointer stability mean in this context?

like image 862
np20 Avatar asked Jan 26 '23 12:01

np20


1 Answers

Pointer stability” means that a pointer to an element remains valid (is not invalidated) so long as the element is present, allowing code to cache pointers to elements even when the underlying container is mutated. Saying that a container has pointer stability is the same as saying that it doesn’t move elements in memory; their addresses do not change. Pointer stability/invalidation is the same as reference stability/invalidation.

This is explanation from the page you posted: https://abseil.io/docs/cpp/guides/container (Abseil containers).

like image 184
Alex F Avatar answered Jan 28 '23 00:01

Alex F