std::inout_ptr
From cppreference.com
< cpp | memory | inout ptr t
C++
Feature test macros (C++20)
Concepts library (C++20)
Metaprogramming library (C++11)
Ranges library (C++20)
Filesystem library (C++17)
Concurrency support library (C++11)
Execution control library (C++26)
Memory management library
Uninitialized memory algorithms
Constrained uninitialized memory algorithms
Memory resources
Uninitialized storage (until C++20)
Garbage collector support (until C++23)
(exposition only*)
(C++11)
(C++23)
(C++11)
(C++17)
(C++11)
(C++11)
(C++20)
(C++20)
(C++17)
(C++11)
(C++17)
(C++20)
(C++17)
(C++17)
(C++17)
(C++17)
(C++17)
(C++17)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++17)
(C++17)
(C++17)
(C++17)
(C++17)
(C++17)
(C++17)
(C++17)
(until C++20*)
(until C++20*)
(until C++20*)
(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)
(C++11)
(C++11)
(C++17)
(C++20)
(C++17)
(C++11)
(C++11)
(C++11)
(until C++17*)
(C++11)
(C++17)
(C++26)
(C++26)
(C++11)
(C++11)
(C++11)
(C++23)
(C++23)
(C++11)
(C++20)
(C++11)
(C++11)
(C++20)
(C++26)
std::inout_ptr_t
Member functions
Non-member functions
inout_ptr
Defined in header
<memory>
template< class Pointer = void, class Smart, class... Args >
auto inout_ptr( Smart& s, Args&&... args );
(since C++23)
auto inout_ptr( Smart& s, Args&&... args );
Returns an inout_ptr_t
with deduced template arguments that captures arguments for resetting by reference.
The program is ill-formed if construction of the return value (see below) is ill-formed.
Contents
[edit] Parameters
s
-
the object (typically a smart pointer) to adapt
args...
-
the arguments for resetting to capture
[edit] Return value
std::inout_ptr_t <Smart, P, Args&&>(s, std::forward <Args>(args)...), where P
is
-
Pointer
, ifPointer
is not a void type, otherwise, - Smart::pointer, if it is valid and denotes a type, otherwise,
- Smart::element_type*, if Smart::element_type is valid and denotes a type, otherwise,
- std::pointer_traits <Smart>::element_type*.
[edit] Notes
Users may specify the template argument for the template parameter Pointer
, in order to interoperate with foreign functions that take a Pointer*.
As all arguments for resetting are captured by reference, the returned inout_ptr_t
should be a temporary object destroyed at the end of the full-expression containing the call to the foreign function, in order to avoid dangling references.
Feature-test macro | Value | Std | Feature |
---|---|---|---|
__cpp_lib_out_ptr |
202106L |
(C++23) | std::out_ptr , std::inout_ptr
|
202311L |
(C++26) | freestanding std::out_ptr and std::inout_ptr
|
[edit] Example
This section is incomplete
Reason: no example
Reason: no example
[edit] See also
(C++23)
out_ptr_t
with an associated smart pointer and resetting arguments (function template) [edit]