std::inout_...torPointer*,(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

πŸ’… std::inout_...torPointer*,(3) πŸ’…

okay so bestie, welcome to the C++ Standard Libary page for std::inout_...torPointer*,(3). The title is giving keyboard-smash realness, but the content is extremely specific pointer-conversion business, and honestly? We respect it. 🫢✨

πŸ“› NAME πŸ“›

std::inout_ptr_t::operatorPointer*, -
std::inout_ptr_t::operatorPointer*,

πŸ¦‹ Synopsis πŸ¦‹

operator Pointer*() const noexcept; (1) (since C++23)
operator void**() const noexcept;   (2) (since C++23)

These functions expose the address of a Pointer or void* object to a foreign function which will generally release the ownership represented by its value and then re-initialize it. No cap, that's the whole plot.

  1. Converts *this to the address of the stored Pointer object. πŸ’…
  2. Converts *this to the address of a void* object. This conversion function participates in overload resolution only if Pointer is not same as void*, and the program is ill-formed if Pointer is not a pointer type. The initial value of the void* object is equal to the value of the stored Pointer object converted to void*, and any modification to it affects the Pointer value used in the destructor.
UB alert: accessing the void* object outside the lifetime of *this has undefined behavior. Do not do that, bestie β€” literally do not. 😭

Once one of these two conversion functions has been called on an inout_ptr_t object, the other shall not be called on it, otherwise the behavior is undefined. Pick one and commit, periodt. πŸ’…

🌸 Parameters 🌸

(none) β€” yes, literally none.

πŸ‘‘ Return value πŸ‘‘

  1. The address of the stored Pointer object.
  2. 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 the value held by adapted Smart object before construction.

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 Pointer member subobject may be used for both conversion functions, and (2) may directly returns its address reinterpret_cast to void**.

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.

ngl, the example slot is empty. It's giving unfinished homework, but we move. πŸ™ˆ

🏷️ Category:

  • Todo no example

source/version and date check, bestie: this page comes from http://cppreference.com, dated 2024.06.10, and it's page std::inout_...torPointer*,(3). Mwah πŸ’‹βœ¨

πŸ“¦ where this page comes from