std::atomic::fetch_xor(3)

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

🌸 std::atomic::fetch_xor(3) 🌸

okay so bestie, this is the C++ Standard Libary manual page for std::atomic::fetch_xor β€” yes, that’s how the manual name is spelled in the header, no cap πŸ™ˆ. It’s giving atomic bit-flipping main character energy ✨.


πŸ’– NAME πŸ’–

std::atomic::fetch_xor β€” literally std::atomic::fetch_xor, periodt πŸ’….

πŸ¦‹ Synopsis πŸ¦‹

okay so this one is a member only of atomic<Integral > specializations:

T fetch_xor( T arg, std::memory_order order =
       (1) (since C++11)
                                  std::memory_order_seq_cst ) noexcept;
T fetch_xor( T arg, std::memory_order order =
                                  std::memory_order_seq_cst ) volatile
       (2) (since C++11)
          noexcept;

Atomically replaces the current value with the result of bitwise XOR of the value and arg πŸ’₯. The operation is a read-modify-write operation, and memory is affected according to the value of order.

deprecated alert, bestie: since C++20, it is deprecated if std::atomic<T>::is_always_lock_free is false and overload (2) participates in overload resolution. So if that condition hits, it’s deprecated β€” not cute, but true 😭.

πŸ’… Parameters πŸ’…

  • arg β€” the other argument of bitwise XOR.
  • order β€” memory order constraints to enforce.

πŸŽ€ Return value πŸŽ€

It returns the value immediately preceding the effects of this function in the modification order of *this 🫢.

πŸ‘‘ See also πŸ‘‘

  • atomic_fetch_xor β€” replaces the atomic object with the result of bitwise XOR.
  • atomic_fetch_xor_explicit β€” with a non-atomic argument and obtains the previous value of the atomic.
  • (C++11), (C++11), (function template) β€” the version and function-template tags from the original See also table, all present and accounted for πŸ’….

mwah πŸ’‹ β€” source: http://cppreference.com, version/date: 2024.06.10.

πŸ“¦ where this page comes from