std::atomic...or_explicit(3)

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

πŸŽ€ NAME πŸŽ€

std::atomic_fetch_xor,std::atomic_fetch_xor_explicit - std::atomic_fetch_xor,std::atomic_fetch_xor_explicit β€” that’s the NAME line, bestie. This page is from the C++ Standard Libary manual, and the header title folded in up here is std::atomic...or_explicit(3). ✨


✨ Synopsis ✨

Defined in header <atomic>
template< class T >

T atomic_fetch_xor( std::atomic<T>* obj,
(1) (since C++11)

                        typename std::atomic<T>::value_type arg )
noexcept;
template< class T >

T atomic_fetch_xor( volatile std::atomic<T>* obj,
(2) (since C++11)

                        typename std::atomic<T>::value_type arg )
noexcept;
template< class T >

T atomic_fetch_xor_explicit( std::atomic<T>* obj,
                             typename std::atomic<T>::value_type
(3) (since C++11)
arg,

                             std::memory_order order) noexcept;
template< class T >

T atomic_fetch_xor_explicit( volatile std::atomic<T>* obj,
                             typename std::atomic<T>::value_type
(4) (since C++11)
arg,

                             std::memory_order order) noexcept;

okay so what it does: it atomically replaces the value pointed by obj with the result of bitwise XOR between the old value of obj and arg. Then it returns the value obj held previously. πŸ’…

The operation is performed as if the following is executed:

1,2) obj->fetch_xor(arg)
3,4) obj->fetch_xor(arg, order)
🚨 IMPORTANT, bestie: if std::atomic<T> has no fetch_xor member (this member is only provided for integral types except bool), the program is ill-formed. No cap.

🌸 Parameters 🌸

  • obj β€” pointer to the atomic object to modify.
  • arg β€” the value to bitwise XOR to the value stored in the atomic object.
  • order β€” the memory synchronization ordering.

πŸ’– Return value πŸ’–

The value immediately preceding the effects of this function in the modification order of *obj. That’s the previous value, bestie. 🫢


πŸ¦‹ Example πŸ¦‹

This section is incomplete Reason: no example

😭 literally what the page says β€” not me being lazy.


🧚 Defect reports 🧚

The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

  • DR: P0558R1
    • Applied to: C++11
    • Behavior as published: exact type match was required because T is only deduced from multiple arguments
    • Correct behavior: T was deduced from obj

πŸ‘€ See also πŸ‘€

  • fetch_xor β€” atomically performs bitwise XOR between the argument and the value of the atomic object and obtains the value held previously (public member function of std::atomic<T>).
  • atomic_fetch_or (C++11), atomic_fetch_or_explicit (C++11) β€” replaces the atomic object with the result of bitwise OR with a non-atomic argument and obtains the previous value of the atomic (function template).
  • atomic_fetch_and (C++11), atomic_fetch_and_explicit (C++11) β€” replaces the atomic object with the result of bitwise AND with a non-atomic argument and obtains the previous value of the atomic (function template).
  • C documentation for atomic_fetch_xor, atomic_fetch_xor_explicit.

🏷️ Category 🏷️

  • Todo no example

🫢 That’s the whole page, bestie. Source/version/date sign-off: http://cppreference.com Β· 2024.06.10 Β· std::atomic...or_explicit(3). Periodt. πŸ’–

πŸ“¦ where this page comes from