STD::LOCK_GUARD(3)
π std::lock_guard< _Mutex > π
okay bestie, gather round, because we're talking about std::lock_guard< _Mutex > from the std namespace, and it lives in the Library Functions Manual. it's a simple scoped lock type. that's the whole vibe. simple. scoped. lock. periodt. π
β¨ NAME β¨
std::lock_guard< _Mutex > β a simple scoped lock type. no cap, that's literally the tagline.
πΈ SYNOPSIS πΈ
#include <mutex>
π¦ Public Types π¦
typedef _Mutex mutex_typeβ yeah so this is just_Mutexwearing a little name tag. that's the mutex type you're working with, bestie.
π Public Member Functions π
lock_guard (const lock_guard &)=deleteβ copy constructor? deleted. you cannot copy this. not today, not ever. πlock_guard (mutex_type &__m)β the main character constructor. hand it a mutex reference and it locks it.lock_guard (mutex_type &__m, adopt_lock_t) noexceptβ the "I already locked it myself, don't touch anything" constructor, markednoexcept.lock_guard & operator= (const lock_guard &)=deleteβ copy assignment? also deleted. assignment is NOT giving. π«
π Detailed Description π
template<typename _Mutex>
class std::lock_guard< _Mutex >
a simple scoped lock type. π
so here's the tea: a lock_guard controls mutex ownership within a scope, and it releases that ownership in the destructor. that's it. that's the whole job. you make one, it owns the mutex for as long as it's alive, and the second it dies (scope ends, bye bye), the mutex gets released. RAII queen behavior honestly. π₯
Since
C++11 β she's been iconic since 2011 and she's not slowing down. β
π«Ά Author π«Ά
Generated automatically by Doxygen for libstdc++ from the source code. so like, a robot wrote this, but a very thorough robot. respect. π€β¨
heads up bestie: both the copy constructor and the copy assignment operator are=deleted, so if you try to copy alock_guardthe compiler will simply refuse. that's not a bug, that's the design, and it's protecting you fr fr. π
and that's the whole page, babe β this was std::lock_...d< _Mutex >(3) from the libstdc++ girlies, delivered to you straight from the Library Functions Manual. thanks for coming to my ted talk, go forth and guard your scopes responsibly. mwah. πππ¦
π¦ where this page comes from
- arch rolling: gcc 16.2.1+r23+gd564253eb6c8-1 Β· GPL-3.0-or-later WITH GCC-exception-3.1 AND GFDL-1.3-or-later
- fedora 44: libstdc++-docs 16.0.1-0.10.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
- fedora 44: libstdc++-docs 16.2.1-2.fc44
- fedora 44: libstdc++-docs 16.2.1-3.fc44 Β· GPL-3.0-or-later AND LGPL-3.0-or-later AND (GPL-3.0-or-later WITH GCC-exception-3.1) AND (GPL-3.0-or-later WITH Texinfo-exception) AND (LGPL-2.1-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GCC-exception-2.0) AND (GPL-2.0-or-later WITH GNU-compiler-exception) AND BSL-1.0 AND GFDL-1.3-or-later AND Linux-man-pages-copyleft-2-para AND SunPro AND BSD-1-Clause AND BSD-2-Clause AND BSD-2-Clause-Views AND BSD-3-Clause AND BSD-4-Clause AND BSD-Source-Code AND Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 WITH LLVM-Exception) AND ZPL-2.1 AND ISC AND LicenseRef-Fedora-Public-Domain AND HP-1986 AND curl AND Martin-Birgmeier AND HPND-Markus-Kuhn AND dtoa AND SMLNJ AND AMD-newlib AND OAR AND HPND-merchantability-variant AND HPND-Intel
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms