std::atomic_flag::clear(3)

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

πŸ’… std::atomic_flag::clear(3) πŸ’…

okay so bestie, this is the C++ Standard Libary page for std::atomic_flag::clear β€” yes, the manual name is literally right there, and we’re about to make it make sense. 🫢

✨ NAME ✨

std::atomic_flag::clear β€” std::atomic_flag::clear. That’s the name. Iconic, no notes. πŸ’–

🌸 Synopsis 🌸

Defined in header <atomic>.

void clear( std::memory_order order =                          (1)
(since C++11)
std::memory_order_seq_cst ) volatile noexcept;
void clear( std::memory_order order =                          (2)
(since C++11)
std::memory_order_seq_cst ) noexcept;

So it atomically changes the state of a std::atomic_flag to clear (false). That’s the main character move. ✨

🚨 big warning, bestie: if order is one of std::memory_order_consume, std::memory_order_acquire and std::memory_order_acq_rel, the behavior is undefined. not a slay. do not do it.

πŸŽ€ Parameters πŸŽ€

  • order β€” the memory synchronization ordering. that’s the whole parameter, and it’s lowkey important.

πŸ’€ Defect reports πŸ’€

the following behavior-changing defect reports were applied retroactively to previously published C++ standards. retroactive lore, fr fr.

  • DR LWG 2138 β€” applied to C++11. Behavior as published: order could be std::memory_order_consume. Correct behavior: the behavior is undefined in this case. 😭

πŸ‘‘ See also πŸ‘‘

  • test_and_set β€” atomically sets the flag to true and obtains its previous value (public member function)
  • atomic_flag_clear (C++11) β€” atomically sets the value of the flag to false (function)
  • atomic_flag_clear_explicit (C++11) β€” atomically sets the value of the flag to false (function)
  • memory_order (C++11) β€” defines memory ordering constraints for the given atomic operation (enum)

cute sign-off time πŸŽ€: source is http://cppreference.com, version/date is 2024.06.10, and the page is std::atomic_flag::clear(3). bye bestie, go clear that flag safely, mwah πŸ’‹βœ¨

πŸ“¦ where this page comes from