std::inout_ptr_t<Smart,Pointer,Args...>::operator Pointer*, std::inout_ptr_t<Smart,Pointer,Args...>::operator void**
operator Pointer*() const noexcept; | (1) |
(since C++23) (constexpr since C++26) |
operator void**() const noexcept; | (2) | (since C++23) |
Exposes 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.
*this to the address of stored Pointer object.*this, the behavior is undefined.*this to the address of a void* object.std::is_same_v<Pointer, void*> is false.std::is_pointer_v<Pointer> is false, the program is ill-formed.ptr satisfying all following conditions: - The initial value of
*ptris equivalent to the value of the storedPointerobject converted to void*. - Any modification of
*ptrthat is not followed by a subsequent modification of*thisaffects thePointervalue used in the destructor.
*this, the behavior is undefined.*ptr is accessed outside the lifetime of *this, the behavior is undefined.Return value
Pointer object.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
Pointermember subobject may be used for both conversion functions, and operatorvoid** may directly returns its addressreinterpret_castto 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 operatorPointer* (or operatorvoid**) has been called.
Example
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/cpp/memory/inout_ptr_t/operator_ptr