Namespaces
Variants
Views
Actions

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

From cppreference.com
< cpp‎ | memory‎ | inout ptr t
 
 
Utilities library
Language support
Type support (basic types, RTTI)
Library feature-test macros (C++20)
Dynamic memory management
Program utilities
Coroutine support (C++20)
Variadic functions
Debugging support
(C++26)
Three-way comparison
(C++20)
(C++20)(C++20)(C++20)
(C++20)(C++20)(C++20)
General utilities
Date and time
Function objects
Formatting library (C++20)
(C++11)
Relational operators (deprecated in C++20)
Integer comparison functions
(C++20)(C++20)(C++20)   
(C++20)
Swap and type operations
(C++14)
(C++11)
(C++11)
(C++11)
(C++17)
Common vocabulary types
(C++11)
(C++17)
(C++17)
(C++17)
(C++11)
(C++17)
(C++23)
Elementary string conversions
(C++17)
(C++17)

 
Dynamic memory management
Uninitialized memory algorithms
Constrained uninitialized memory algorithms
Allocators
Garbage collection support
(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 inout_ptr_t( Smart &sp, Args... args );
(1) (since C++23)
inout_ptr_t( const inout_ptr_t& ) = delete;
(2) (since C++23)
1) Creates an inout_ptr_t. Adapts sp as if binds it to the Smart& member, captures every argument t in args... as if initializes the corresponding member of type T in Args... with std::forward<T>(t), then initializes the stored Pointer with sp if Smart is a pointer type, otherwise, initializes it with sp.get(). sp.release() may be called if Smart is not a pointer type, in which case it will not be called again within the destructor.
2) Copy constructor is explicitly deleted. inout_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

If Smart is not a pointer type and sp.release() is not called by the constructor, it may be called by the destructor before resetting sp.

Every argument in args... is moved into the created inout_ptr_t if it is of an object type, or transferred into the created inout_ptr_t as-is if it is of a reference type.

The constructor of inout_ptr_t is allowed to throw exceptions. For example, when sp is an intrusive pointer with a control block, the allocation for the new control block may be performed within the constructor rather than the destructor.

[edit] Example