std::inout_...:inout_ptr_t(3)
π std::inout_ptr_t::inout_ptr_t π
okay bestie so this is straight out of the C++ Standard Library manual, page std::inout_...:inout_ptr_t(3), and it's literally the constructor page for std::inout_ptr_t::inout_ptr_t. we're doing constructor lore today π«Ά
β¨ NAME β¨
std::inout_ptr_t::inout_ptr_t β yes it's the same name twice, that's not a typo, that's just how constructors are built π it's the constructor, of inout_ptr_t, named inout_ptr_t. iconic behavior honestly.
πΈ Synopsis πΈ
explicit inout_ptr_t( Smart &sp, Args... args ); (1) (since C++23)
inout_ptr_t( const inout_ptr_t& ) = delete; (2) (since C++23)
okay so what do these two actually do, let me break it down fr fr:
- so this one creates an
inout_ptr_t. it adaptsspas if it binds it to theSmart&member, then captures every argumenttinargs...as if it initializes the corresponding member of typeTinArgs...withstd::forward<T>(t), and then it initializes the storedPointerwithspifSmartis a pointer type β otherwise it initializes it withsp.get(). and bestie listen,sp.release()may be called ifSmartis not a pointer type, and in that case it will not be called again inside the destructor. noted. π - the copy constructor is explicitly deleted.
inout_ptr_tis neither copyable nor movable. she does not get copied, she does not get moved, she simply is. main character energy only π
π Parameters π
spβ the object (typically a smart pointer) to adapt πargs...β the arguments used for resetting to capture
π¦ Return value π¦
(none) β yeah, nothing, nada, she's a constructor, she returns vibes only β¨
π₯ Exceptions π₯
may throw implementation-defined exceptions. so like, don't assume she's always chill π
π Notes π
so 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. keep that in mind bestie.
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. two different lanes, same destination π
π¨ and here's the one that matters: the constructor ofinout_ptr_tis allowed to throw exceptions. for example, whenspis an intrusive pointer with a control block, the allocation for the new control block may be performed within the constructor rather than the destructor. so like, the throwing can happen earlier than u expected, no cap.
π Example π
This section is incomplete
Reason: no example
like, she's gorgeous but she's got no outfit pics yet π
β Category β
- Todo no example
and that's the whole page fr fr π this was std::inout_...:inout_ptr_t(3) from the cppreference vibes, served up 2024.06.10 β go off and construct responsibly bestie πβ¨π
π¦ 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