STD::SCOPED_LOCK(3cxx)

πŸ‘‘ std::scoped_lock< _MutexTypes > β€” a scoped lock type for multiple lockable objects

okay bestie so you found your way into section 3cxx of the manual, which is where the C++ library stuff lives πŸ’œ and this one?? this one is a banger. it's the lock that holds several things at once and then politely lets go when it goes out of scope. main character energy fr fr.


✨ NAME ✨

std::scoped_lock< _MutexTypes > β€” A scoped lock type for multiple lockable objects.

like. its whole job. its whole personality. locking multiple lockables. 🫢


🌸 SYNOPSIS 🌸

#include <mutex>

πŸ’… Public Member Functions

  • scoped_lock (_MutexTypes &... __m) β€” the constructor, takes all your mutexes by reference πŸ™ˆ
  • scoped_lock (adopt_lock_t, _MutexTypes &... __m) noexcept β€” the "no bestie I already locked them, just adopt them" constructor, and it's noexcept so it will NOT be dramatic about it
  • scoped_lock (const scoped_lock &)=delete β€” copy constructor? deleted. not a thing. not allowed. absolutely not. πŸ’€
  • scoped_lock & operator= (const scoped_lock &)=delete β€” copy assignment? also deleted. we do not duplicate locks in this house 🚫

πŸ¦‹ Detailed Description πŸ¦‹

template<typename... _MutexTypes>
    class std::scoped_lock< _MutexTypes >
"A scoped lock type for multiple lockable objects.

A scoped_lock controls mutex ownership within a scope, releasing ownership in the destructor.


πŸŽ€ Since

C++17 ✨ (yes, she's been iconic since 2017, we been knew)


🧚 Author 🧚

Generated automatically by Doxygen for libstdc++ from the source code.

(not a human, just a little robot doing its best 🫢✨)


🌈 see you later bestie 🌈

that's the whole page! and just so you know, this lil' beauty ships with libstdc++, and you'll find it filed under std::scoped_lock< _MutexTypes >(3cxx). go lock something safely, periodt πŸ’…πŸ‘‘

πŸ“¦ where this page comes from