std::inout_ptr(3)
π NAME π
Okay so this is the std::inout_ptr(3) page from the C++ Standard Libary β yes, the header spells it like that bestie, we are not editing the lore β and the NAME section is literally std::inout_ptr β std::inout_ptr. Self-titled album energy, iconic.
π¦ Synopsis π¦
Defined in header <memory>
template< class Pointer = void, class Smart, class... Args >
auto inout_ptr( Smart& s, Args&&... args );
(since C++23)
It 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. So yeah, that's a hard no from the compiler π.
πΈ Parameters πΈ
sβ the object (typically a smart pointer) to adapt.args...β the arguments for resetting to capture.
π Return value π
It gives you:
std::inout_ptr_t<Smart, P, Args&&>(s, std::forward<Args>(args)...)
where P is:
Pointer, ifPointeris not same asvoid, otherwise,Smart::pointer, if it is valid and denotes a type, otherwise,Smart::element_type*, ifSmart::element_typeis valid and denotes a type, otherwise,std::pointer_traits<Smart>::element_type*.
π₯ Notes π₯
Users may specify the template argument for the template parameter Pointer, in order to interoperate with foreign functions that take a Pointer*. That's the customization moment, iykyk.
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.
π¨ Dangling references are not the vibe. Keep that temporary alive only until the end of the full-expression, periodt.
Feature-test macro tea β:
- Feature-test macro
__cpp_lib_out_ptr; Value202106L; Std(C++23); Featurestd::out_ptr,std::inout_ptr - Feature-test macro
__cpp_lib_out_ptr; Value202311L; Std(C++26); Feature freestandingstd::out_ptrandstd::inout_ptr
π Example π
This section is incomplete
Reason: no example
Not the page having zero examples π. It literally says it's incomplete, so no invented demo from me.
π See also π
out_ptr(C++23) β creates anout_ptr_twith an associated smart pointer and resetting arguments (function template).make_unique(C++14) β (function template).make_unique_for_overwrite(C++20) β creates a unique pointer that manages a new object (function template).make_sharedβ creates a shared pointer that manages a new object (function template).make_shared_for_overwrite(C++20) β (function template).
π·οΈ Category π·οΈ
- Todo no example
Okay bestie, that's the whole page. Source is http://cppreference.com, version/date stamp is 2024.06.10, and the manual page is std::inout_ptr(3). Go forth and reset responsibly π
β¨
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms