std::weak_ptr 的 _Get 方法有什么作用,应该在什么时候使用?

What does the _Get method of a std::weak_ptr do and when should it be used?

我正在阅读智能指针,尤其是弱指针。我知道弱指针没有像共享指针那样的类似 get() 方法,因为不确定弱指针是否指向任何东西。然后发现Intellisence提示了_Get()方法

std::weak_ptr的_Get()方法到底是做什么用的,应该在什么时候使用?

从来没有。下划线大写字母名称保留用于实现。作为用户,您永远不应该使用它们。此外,它没有在 weak_ptr's interface 中列出,因此基于它编写的代码将不可移植。

至于它的作用:它可能是一些辅助函数。由于它保留用于 任何使用 的实现,因此进一步研究它没有什么意义,因为它甚至可以在次要版本之间更改(或消失)。

N4140 § 17.6.4.3.2 [global.names] / 1

Certain sets of names and function signatures are always reserved to the implementation: — Each name that contains a double underscore __ or begins with an underscore followed by an uppercase letter (2.12) is reserved to the implementation for any use.