什么是指针稳定性?

What is pointer stability?

这个 link 关于绕绳下降容器的第二段说:

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

在此上下文中,指针稳定性是什么意思?

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.

这是您发布的页面的解释:https://abseil.io/docs/cpp/guides/container(沿绳下降容器)。

指针稳定性意味着指针保证在它指向的对象的生命周期内保持稳定(即指针指向的地址保持不变并且不会改变),除非你做一些事情来破坏它。

操作系统提供给您的进程的虚拟内存space 会将内容保存在相同的地址。尽管物理内存可能会改变。这是 OS 必须注意的事情之一。

参考:Are Pointers stable?