std::out_pt...torPointer*,(3)
π std::out_ptr_t::operatorPointer* β C++ Standard Libary realness π
Okay bestie, this is the std::out_ptr_t::operatorPointer* page from the C++ Standard Libary, and the header is doing that truncated std::out_pt...torPointer*,(3) thing β mysterious, iconic, slightly chaotic. π
πΈ NAME πΈ
std::out_ptr_t::operatorPointer*, β std::out_ptr_t::operatorPointer*, (yes, the same string twice, she's that kind of page π).
β¨ Synopsis β¨
These are the two conversion-operator glow-ups, both noexcept, both since C++23:
operator Pointer*() const noexcept; (1) (since C++23)
operator void**() const noexcept; (2) (since C++23)
So what's the vibe? It exposes the address of a Pointer or void* object to a foreign function which will generally re-initialize it. Little handoff moment, no cap. π«Ά
- Converts
*thisto the address of the storedPointerobject. - Converts
*thisto the address of avoid*object. This conversion function participates in overload resolution only ifPointeris not same asvoid*, and the program is ill-formed ifPointeris not a pointer type. The initial value of thevoid*object is equal the value of the storedPointerobject converted tovoid*, and any modification to it affects thePointervalue used in the destructor. Accessing thevoid*object outside the lifetime of*thishas undefined behavior.
Once one of these two conversion functions has been called on an out_ptr_t object, the other shall not be called on it, otherwise, the behavior is undefined. So like, pick one and commit, bestie. π
π Parameters π
- (none) β literally no parameters, she's self-sufficient. β¨
π Return value π
- The address of the stored
Pointerobject. - The address of the
void*object that satisfies aforementioned requirements.
π Notes π
If the object pointed by the return value has not been rewritten, it is equal to nullptr. Cute.
On common implementations, the object representation of every Pointer that is a pointer type is compatible with that of void*, and therefore these implementations typically store the void* object within the storage for the Pointer object, no additional storage needed:
- If the implementation enables type-based alias analysis (which relies on the strict aliasing rule), a properly aligned
std::byte[sizeof(void*)]member subobject may be used, and both conversion functions return the address of objects implicitly created within the array. - Otherwise, a
Pointermember subobject may be used for both conversion functions, and (2) may directly returns its addressreinterpret_casttovoid**.
If Pointer is a pointer type whose object representation is incompatible with that of void*, an additional bool flag may be needed for recording whether (1) (or (2)) has been called.
π Example π
This section is incomplete.
Reason: no example.
Not me showing up to the example section and it's giving "under construction" π no example yet, bestie.
π§ Category π§
- Todo no example
Okay that's the whole page, periodt. Shoutout to the source http://cppreference.com, version/date 2024.06.10, and the footer title std::out_pt...torPointer*,(3) β mwah, slay. ππ
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms