I was reading about smart pointers, weak pointers in particular. I understood that weak pointers do not have a similar get()
method like shared pointers, because it's uncertain whether the weak pointer is pointing at anything. Then I found that Intellisence suggested _Get()
method.
What exactly does the _Get()
method of std::weak_ptr do, and when should it be used?
Never. Underscore-capital-letter names are reserved for the implementation. You, as a user, are not supposed to use them, ever. Furthermore, it is not listed in weak_ptr
's interface, so code written depending on it would not be portable.
As for what it does: it probably is some helper function. Since it's reserved for the implementation for any use, it makes little sense to delve into it further, as it is allowed to change (or disappear) between even minor versions.
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.