Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::inout_ptr_t<Smart,Pointer,Args...>::operator Pointer*,std::inout_ptr_t<Smart,Pointer,Args...>::operator void**

      From cppreference.com
      <cpp‎ |memory‎ |inout ptr t
       
       
      Memory management library
      (exposition only*)
      Allocators
      Uninitialized memory algorithms
      Constrained uninitialized memory algorithms
      Memory resources
      Uninitialized storage(until C++20)
      (until C++20*)
      (until C++20*)
      Garbage collector support(until C++23)
      (C++11)(until C++23)
      (C++11)(until C++23)
      (C++11)(until C++23)
      (C++11)(until C++23)
      (C++11)(until C++23)
      (C++11)(until C++23)
       
      std::inout_ptr_t
      Member functions
      inout_ptr_t::operator Pointer*inout_ptr_t::operator void**
      Non-member functions
       
      operator Pointer*()constnoexcept;
      (1)(since C++23)
      operatorvoid**()constnoexcept;
      (2)(since C++23)

      Exposes the address of aPointer orvoid* object to a foreign function which will generally release the ownership represented by its value and then re-initialize it.

      1) Converts*this to the address of storedPointer object.
      2) Converts*this to the address of avoid* object. This conversion function participates in overload resolution only ifPointer is not same asvoid*, and the program is ill-formed ifPointer is not a pointer type.
      The initial value of thevoid* object is equal the value of the storedPointer object converted tovoid*, and any modification to it affects thePointer value used in thedestructor. Accessing thevoid* object outside the lifetime of*this has undefined behavior.

      Once one of these two conversion functions has been called on aninout_ptr_t object, the other shall not be called on it, otherwise, the behavior is undefined.

      Contents

      [edit]Parameters

      (none)

      [edit]Return value

      1) The address of storedPointer object.
      2) The address of thevoid* object that satisfies aforementioned requirements.

      [edit]Notes

      If the object pointed by the return value has not been rewritten, it is equal to the value held by adaptedSmart object before construction.

      On common implementations, the object representation of everyPointer that is a pointer type is compatible with that ofvoid*, and therefore these implementations typically store thevoid* object within the storage for thePointer object, no additional storage needed:

      • If the implementation enables type-based alias analysis (which relies on thestrict aliasing rule), a properly alignedstd::byte[sizeof(void*)] member subobject may be used, and both conversion functions return the address of objectsimplicitly created within the array.
      • Otherwise, aPointer member subobject may be used for both conversion functions, and(2) may directly returns its addressreinterpret_cast tovoid**.

      IfPointer is a pointer type whose object representation is incompatible with that ofvoid*, an additionalbool flag may be needed for recording whether(1) (or(2)) has been called.

      [edit]Example

      This section is incomplete
      Reason: no example
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/memory/inout_ptr_t/operator_ptr&oldid=130200"

      [8]ページ先頭

      ©2009-2026 Movatter.jp