std::atomic...or_explicit(3)
π 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: ifstd::atomic<T>has nofetch_xormember (this member is only provided for integral types exceptbool), 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
Tis only deduced from multiple arguments - Correct behavior:
Twas deduced fromobj
- Applied to:
π 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 ofstd::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
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms