std::unique...k::operator=(3)

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

okay bestie, welcome to std::unique...k::operator=(3) from the C++ Standard Libary manual β€” yes, the manual name says Libary in the header, and we are not fixing it, that's canon πŸ’….

πŸ’– NAME πŸ’–

  • std::unique_lock::operator= β€” literally std::unique_lock::operator=, the move assignment operator, here to replace contents and serve move-semantics realness 🫢

✨ Synopsis ✨

unique_lock& operator=( unique_lock&& other );  (since C++11)

Move assignment operator energy: it replaces the contents with those of other using move semantics. no cap, that's the whole job πŸ’«

⚠️ important vibe check: if, prior to the call, *this has an associated mutex and has acquired ownership of it, the mutex is unlocked.

πŸŽ€ Parameters πŸŽ€

  • other β€” another unique_lock to replace the state with. that's it, that's the parameter 🫢

🌸 Return value 🌸

  • *this β€” yes queen, it returns itself πŸ‘‘

πŸ”₯ Exceptions πŸ”₯

Throws nothing. literally nothing. silence. πŸ’€

but bestie, there's defect-report lore below, so don't stop reading 😭

πŸ“‹ Defect reports πŸ“‹

The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

  • DR: LWG 2104
    • Applied to: C++11
    • Behavior as published: the move assignment operator was noexcept, but it may throw an exception in the case of undefined behavior^[1]
    • Correct behavior: it is not noexcept
  1. ↑ For example, *this is constructed with std::adopt_lock, but the calling thread does not have the ownership of the associated mutex. In this case, *this cannot properly release the ownership of the associated mutex, and it may result in an exception to be thrown.

okay that's the whole page, bestie β€” source: http://cppreference.com, version/date: 2024.06.10, page: std::unique...k::operator=(3). go forth and move-assign responsibly πŸ’–βœ¨

πŸ“¦ where this page comes from