std::atomic::fetch_or(3)

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

πŸ’– NAME πŸ’–

NAME vibe check: std::atomic::fetch_or β€” std::atomic::fetch_or. This is the std::atomic::fetch_or(3) page from the C++ Standard Libary manual, and it's a member only of atomic<Integral > specializations. slay, bestie πŸ’….

πŸ“œ Synopsis πŸ“œ

okay so here's the synopsis, copied exactly because we do not play with signatures:

          member only of atomic<Integral > specializations
          T fetch_or( T arg, std::memory_order order =
       (1) (since C++11)
                                 std::memory_order_seq_cst ) noexcept;
          T fetch_or( T arg, std::memory_order order =
                                 std::memory_order_seq_cst ) volatile
       (2) (since C++11)
          noexcept;

So overload (1) is the regular one β€” noexcept, since C++11. Overload (2) is the volatile one β€” also noexcept, also since C++11. Both take T arg and std::memory_order order = std::memory_order_seq_cst.

Atomically replaces the current value with the result of bitwise OR of the value and arg. It's a read-modify-write operation. Memory is affected according to the value of order. iykyk ✨

🚨 technical caveat, no cap: it is deprecated if std::atomic<T>::is_always_lock_free is false and β€” since C++20 β€” overload (2) participates in overload resolution. that's the fine print, bestie.

🌸 Parameters 🌸

  • arg β€” the other argument of bitwise OR 🫢
  • order β€” memory order constraints to enforce ✨

πŸŽ€ Return value πŸŽ€

The value immediately preceding the effects of this function in the modification order of *this. that's the return value, periodt πŸ’…

πŸ‘€ See also πŸ‘€

the cross-refs are giving:

atomic_fetch_or          replaces the atomic object with the result
                         of bitwise OR
atomic_fetch_or_explicit with a non-atomic argument and obtains the
                         previous value
(C++11)                  of the atomic
(C++11)                  (function template)

mwah πŸ’‹ β€” source: http://cppreference.com; version/date: 2024.06.10; page: std::atomic::fetch_or(3). now go atomically slay, bestie 🫢✨

πŸ“¦ where this page comes from