std::unique...unique_lock(3)
π 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
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms