Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::out_ptr_t<Smart,Pointer,Args...>::out_ptr_t

      From cppreference.com
      <cpp‎ |memory‎ |out 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)
       
       
      explicit out_ptr_t( Smart&sp, Args...args);
      (1)(since C++23)
      out_ptr_t(const out_ptr_t&)= delete;
      (2)(since C++23)
      1) Creates anout_ptr_t. Adaptssp as if binds it to theSmart& member, captures every argumentt inargs... as if initializes the corresponding member of typeT inArgs... withstd::forward<T>(t), then value-initializes the storedPointer.
      Then callssp.reset() if the expression is well-formed; otherwise, callssp= Smart() ifstd::is_default_constructible_v<Smart> istrue. The program is ill-formed if both resetting operations are ill-formed.
      2) Copy constructor is explicitly deleted.out_ptr_t is neither copyable nor movable.

      Contents

      [edit]Parameters

      sp - the object (typically a smart pointer) to adapt
      args... - the arguments used for resetting to capture

      [edit]Return value

      (none)

      [edit]Exceptions

      May throw implementation-defined exceptions.

      [edit]Notes

      After construction, thePointer orvoid* object pointed by the return value of either conversion function is equal tonullptr.

      Every argument inargs... is moved into the createdout_ptr_t if it is of an object type, or transferred into the createdout_ptr_t as-is if it is of a reference type.

      The constructor ofout_ptr_t is allowed to throw exceptions. For example, whensp is astd::shared_ptr, the allocation for the new control block may be performed within the constructor rather than the destructor.

      [edit]Example

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

      [8]ページ先頭

      ©2009-2026 Movatter.jp