std::once_flag(3)

πŸ’– std::once_flag(3) πŸ’–

okay bestie, welcome to the std::once_flag page β€” it lives in the Library Functions Manual and it's literally just a flag type, but it's a flag type that matters, so let's get into it πŸŽ€


✨ NAME ✨

std::once_flag β€” the flag type that std::call_once uses. that's it, that's the whole job, and she does it flawlessly πŸ’…


🌸 SYNOPSIS 🌸

#include <mutex>

πŸ¦‹ Public Member Functions

  • once_flag(const once_flag &) = delete β€” deleted copy constructor. no copies, bestie, she's one of a kind πŸ‘‘
  • once_flag &operator=(const once_flag &) = delete β€” deleted assignment operator. and no reassigning either. she does not do hand-me-downs πŸ’€

🫢 Friends

  • template<typename _Callable, typename... _Args> void call_once(once_flag &__once, _Callable &&__f, _Args &&... __args) β€” invokes a callable and syncs up with every other call that's using the same flag. it's giving coordinated group chat energy ✨

🌈 Detailed Description 🌈

Flag type used by std::call_once.

lowkey that's the entire description and honestly? iconic. she's a flag, she's used by std::call_once, she contains multitudes πŸŽ€


🧚 Constructor & Destructor Documentation 🧚

std::once_flag::once_flag(const once_flag &) [delete]

Deleted copy constructor.

you cannot copy her. periodt. the compiler will simply say no and you will simply have to deal with that 😭


⭐ Member Function Documentation ⭐

once_flag &std::once_flag::operator=(const once_flag &) [delete]

Deleted assignment operator.

you also cannot assign to her. no takebacks, no swapsies, no nothing. she's immutable in spirit and also literally, fr fr πŸ’…


template<typename _Callable, typename... _Args> void call_once(once_flag &__once, _Callable &&__f, _Args &&... __args) [friend]

Invoke a callable and synchronize with other calls using the same flag.

References std::__invoke(), and std::forward(). those two are doing the heavy lifting behind the scenes and we love them for it 🫢


πŸ‘‘ Author πŸ‘‘

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

so like, nobody wrote this, a robot did, and honestly? she ate πŸ€–βœ¨


bestie reminder: this whole page is libstdc++ business, and it's page std::once_flag(3) β€” the flag that makes std::call_once behave. treat her with respect πŸŽ€πŸ’–
πŸ“¦ 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