std::barrier::barrier(3)

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

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

okay so we’re in the C++ Standard Libary manual, section 3, and this page is literally all about std::barrier::barrier. Bestie, it’s giving constructor lore, and we are keeping every single detail, fr fr. ✨


🌸 NAME 🌸

std::barrier::barrier β€” and yes, the name line is std::barrier::barrier - std::barrier::barrier. No cap, that’s the whole vibe. πŸ’…

✨ Synopsis ✨

Here’s the synopsis, bestie:

(1) (since C++20)
constexpr explicit barrier( std::ptrdiff_t expected,
                            CompletionFunction f = CompletionFunction());

(2) (since C++20)
barrier( const barrier& ) = delete;
  1. Constructor (1) sets both the initial expected count for each phase and the current expected count for the first phase to expected. It initializes the completion function object with std::move(f), and then starts the first phase. The behavior is undefined if expected is negative or greater than max(). 😭
  2. Constructor (2) is the copy constructor, and it is deleted. barrier is neither copyable nor movable. Periodt. 🫢

πŸŽ€ Parameters πŸŽ€

  • expected β€” initial value of the expected count. πŸ’–
  • f β€” completion function object to be called on phase completion step. 🌟

πŸ”₯ Exceptions πŸ”₯

  1. Constructor (1) can throw any exception thrown by CompletionFunction's move constructor. 😭

πŸ¦‹ Notes πŸ¦‹

expected is permitted to be zero. However, calling any non-static member function other than the destructor on such barrier results in undefined behavior. In other words, such barrier can only be destroyed. πŸ’€

⚠️ Warning, bestie: zero is allowed, but a zero-expected barrier is basically β€œlook, don’t touch” β€” only the destructor is safe. No cap. πŸ™ˆ

source/version/date check: http://cppreference.com β€’ 2024.06.10 β€’ std::barrier::barrier(3) slay and goodbye πŸ’–βœ¨

πŸ“¦ where this page comes from