std::inout_...:inout_ptr_t(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

πŸ’… 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:

  1. so this one creates an inout_ptr_t. it adapts sp as if it binds it to the Smart& member, then captures every argument t in args... as if it initializes the corresponding member of type T in Args... with std::forward<T>(t), and then it initializes the stored Pointer with sp if Smart is a pointer type β€” otherwise it initializes it with sp.get(). and bestie listen, sp.release() may be called if Smart is not a pointer type, and in that case it will not be called again inside the destructor. noted. πŸ“
  2. the copy constructor is explicitly deleted. inout_ptr_t is 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 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. 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