std::atomic::fetch_and(3)
π NAME π
std::atomic::fetch_and β from the C++ Standard Libary, and yes bestie, this is the atomic bitwise-AND member you call when you need read-modify-write energy without the chaos. π
πΈ Synopsis πΈ
member only of atomic<Integral > specializations
T fetch_and( T arg, std::memory_order order =
(1) (since C++11)
std::memory_order_seq_cst ) noexcept;
T fetch_and( T arg, std::memory_order order =
std::memory_order_seq_cst ) volatile
(2) (since C++11)
noexcept;
Okay so hereβs the tea: this is a member only of atomic<Integral > specializations. It atomically replaces the current value with the result of bitwise AND of the value and arg. The operation is a read-modify-write operation. Memory is affected according to the value of order. β¨
β οΈ It is deprecated ifstd::atomic<T>::is_always_lock_freeisfalseand overload (2) participates in overload resolution.(since C++20)
π Parameters π
argβ the other argument of bitwise AND.orderβ memory order constraints to enforce.
β¨ Return value β¨
The value immediately preceding the effects of this function in the modification order of *this.
π¦ See also π¦
atomic_fetch_andβ replaces the atomic object with the result of bitwise AND with a non-atomic argument and obtains the previous value of the atomic.(C++11)(function template)atomic_fetch_and_explicitβ replaces the atomic object with the result of bitwise AND with a non-atomic argument and obtains the previous value of the atomic.(C++11)(function template)
Source/version and date, for the record: http://cppreference.com β’ 2024.06.10. Byeee, go atomically AND your bits responsibly ππ¦π
π¦ 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