std::unique...unique_lock(3)

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

πŸ’… NAME

std::unique_lock::~unique_lock β€” bestie, this is literally the destructor for std::unique_lock, no cap ✨

So you're browsing the C++ Standard Libary manual (yes that's the manual name, we don't make the rules πŸŽ€) and you landed on the destructor page. Slay, let's get into it.


🌸 Synopsis

~unique_lock();  (since C++11)

That's the whole signature, periodt. Available since C++11. 🫢


πŸ¦‹ DESCRIPTION

Okay so picture this: your unique_lock is done living its best life, and it's time to go. πŸ’€ The destructor destroys the lock β€” that's the main character energy right there.

But here's the iconic part πŸ”₯: if *this has an associated mutex and has acquired ownership of it, then the mutex gets unlocked. The way that it quietly cleans up after itself? Obsessed. πŸ™ˆ

So yeah β€” no manual unlock needed if you were holding it, the destructor handles business on the way out. ✨


🧚 Sign-off

Source and version: http://cppreference.com, dated 2024.06.10 β€” that's the whole page bestie, go forth and let your locks drop at scope exit πŸ’–πŸŽ€πŸŒˆβ­πŸ‘‘

πŸ“¦ where this page comes from