std::experi...e::operator=(3)

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

πŸ’– NAME πŸ’–

okay bestie, welcome to the C++ Standard Libary manual page for std::experimental::unique_resource::operator= β€” the page title is literally std::experi...e::operator=(3) and yes they abbreviated it, iconic behavior. The full name situation is:

std::experimental::unique_resource::operator= β€” std::experimental::unique_resource::operator=


✨ Synopsis ✨

here's the signature, no cap:

unique_resource& operator=( unique_resource&& other )  (library fundamentals TS v3)
       noexcept(/*see below*/);

it's giving move assignment operator energy, and it's from the library fundamentals TS v3 ✨

so what does it actually do? Move assignment operator. It replaces the managed resource and the deleter with other's.

Formally, let RS be the type of stored resource handle:

  • First, calls reset() to dispose the currently owned resource, if any.
  • Then assigns the stored resource handle and the deleter with other's. std::move is applied to the stored resource handle or the deleter of other if std::is_nothrow_move_assignable_v<RS> or std::is_nothrow_move_assignable_v<D> is true respectively. Assignment of the stored resource handle is executed first, unless std::is_nothrow_move_assignable_v<D> is false and std::is_nothrow_move_assignable_v<RS> is true.
  • Finally, sets *this to own the resource if and only if other owned it before assignment, and other not to own the resource.

If std::is_nothrow_move_assignable_v<RS> is true, RS shall satisfy the MoveAssignable requirements; otherwise RS shall satisfy the CopyAssignable requirements. If std::is_nothrow_move_assignable_v<D> is true, D shall satisfy the MoveAssignable requirements; otherwise D shall satisfy the CopyAssignable requirements. Failing to satisfy above requirements results in undefined behavior πŸ˜±πŸ’€


🌈 Parameters 🌈

  • other β€” resource wrapper from which ownership will be transferred 🫢

πŸ’… Return value πŸ’…

it returns *this. periodt. πŸ’…


πŸ”₯ Exceptions πŸ”₯

Any exception thrown in copy-assignment.

noexcept specification:

noexcept(std::is_nothrow_move_assignable_v<RS> &&
          std::is_nothrow_move_assignable_v<D>)

🧚 Notes 🧚

If a copy of a member throws an exception, this mechanism leaves other intact and *this in the released state. bestie behavior honestly 🧚✨


πŸ“ Example πŸ“

This section is incomplete
Reason: no example

πŸ‘‘ See also πŸ‘‘

  • reset β€” disposes or replaces the managed resource (public member function)
  • operator= β€” assigns the unique_ptr (public member function of std::unique_ptr<T,Deleter>)

🌸 Categories 🌸

  • conditionally noexcept
  • Todo no example

that's the whole page, bestie! sourced from http://cppreference.com, dated 2024.06.10, page std::experi...e::operator=(3) β€” slay and stay hydrated πŸ’–πŸ«Άβœ¨

πŸ“¦ where this page comes from