On this page
std::inout_ptr_t<Smart,Pointer,Args...>::~inout_ptr_t
|
(since C++23) |
Resets the adapted Smart object by the value of modified Pointer object (or the void* object if operator void**() has been called) and the captured arguments. release() may be called on the adapted Smart object if it is not called by the constructor.
Let
sdenotes the adaptedSmartobject,args...denotes the captured arguments,pdenotes the value of storedPointer, orstatic_cast<Pointer>(*operator void**())ifoperator void**has been called,SPbeSmart::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*, ifstd::pointer_traits<Smart>::element_typeis valid and denotes a type, otherwise,Pointer,
/*do-release*/denotess.release()if the constructor does not callrelease(), empty otherwise.
If Smart is a pointer type, the destructor performs s = static_cast<Smart>(p);, and the program is ill-formed if sizeof...(Args) > 0;
otherwise, if s.reset(static_cast<SP>(p), std::forward<Args>(args)...) is well-formed, the destructor performs /*do-release*/; if (p) { s.reset(static_cast<SP>(p), std::forward<Args>(args)...); };
otherwise, if std::is_constructible_v<Smart, SP, Args...> is true, the destructor performs /*do-release*/; if (p) { s = Smart(static_cast<SP>(p), std::forward<Args>(args)...); };
otherwise, the program is ill-formed.
Notes
The implementation may allocate the storage for the data structure needed for Smart (e.g. a control block) on construction, in order to leave non-throwing works to the destructor.
Arguments captured by value are destroyed after resetting.
Defect reports
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
| DR | Applied to | Behavior as published | Correct behavior |
|---|---|---|---|
| LWG 3897 | C++23 | the destructor did not update a raw pointer to the null value | it does |
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/w/cpp/memory/inout_ptr_t/%7Einout_ptr_t