std::experi...ource::reset(3)

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

🌸 NAME 🌸

std::experimental::unique_resource::reset β€” std::experimental::unique_resource::reset. yes, it's literally the same name twice, and honestly? iconic. πŸ’…

This is the page from the C++ Standard Libary manual β€” that spelling is the header's, not mine, bestie 😭 β€” and it's all about the reset member of std::experimental::unique_resource. πŸ¦‹


✨ Synopsis ✨

here's the exact synopsis, untouched because code is sacred:

void reset() noexcept; (1) (library fundamentals TS v3)

template< class RR >   (2) (library fundamentals TS v3)
void reset( RR&& r );
  1. Overload (1) β€” Disposes the resource by calling the deleter with the underlying resource handle if the unique_resource owns it. The unique_resource does not own the resource after the call. periodt. πŸ’…
  2. Overload (2) β€” Replaces the resource by calling (1) and then assigns the stored resource handle with std::forward<RR>(r) if std::is_nothrow_assignable_v<RS, RR> is true, otherwise std::as_const(r), where RS is the type of stored resource handle. The unique_resource owns the resource after the call. 🫢

If copy-assignment of the stored resource handle throws an exception, it calls del_(r), where del is the deleter object.

This overload participates in overload resolution only if the selected assignment expression assigning the stored resource handle is well-formed.

The program is ill-formed if del_(r) is ill-formed.

The behavior is undefined if del_(r) results in undefined behavior or throws an exception. so yeah, that's a big ol' "do not pass go" situation πŸ˜­πŸ’€

πŸŽ€ Parameters πŸŽ€

  • r β€” resource handle for a new resource to manage. 🫢

πŸ’– Return value πŸ’–

  • (none) β€” literally no return value, bestie. πŸ’…

🫢 Exceptions 🫢

  • 2) Any exception thrown in assigning the stored resource handle. 😭

🧚 Notes 🧚

The mechanism ensures no leaking of resources. slay, no leaks. ✨


πŸ“ Example πŸ“

This section is incomplete.

Reason: no example.

(not me leaving the example section empty β€” iconic but incomplete πŸ’€)


πŸ‘‘ See also πŸ‘‘

  • reset replaces the managed object β€” (public member function of std::unique_ptr<T,Deleter>). πŸ‘‘

πŸ’… Category πŸ’…

  • Todo no example πŸŽ€

that's the whole page, bestie! πŸ’– source/version: http://cppreference.com, date 2024.06.10 β€” go off, C++ docs πŸ‘‘βœ¨

πŸ“¦ where this page comes from