std::atomic_ref::fetch_and(3)

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

🌸 NAME 🌸

okay so welcome to std::atomic_ref::fetch_and(3) from the C++ Standard Libary β€” yep, that’s the manual name as written here, and we’re keeping it exact, no cap πŸ’…. The NAME is std::atomic_ref::fetch_and β€” std::atomic_ref::fetch_and, same energy, same function, iconic behavior ✨.

✨ Synopsis ✨

Quick vibe check: this is a member only of atomic_ref<Integral> specializations 🫢.

T fetch_and( T arg,
             std::memory_order order = std::memory_order_seq_cst )
const noexcept;

(since C++20) β€” dated, slay, periodt πŸŽ€.

Here’s the tea: it atomically replaces the current value of the referenced object with the result of bitwise AND of the value and arg πŸ”₯. This operation is a read-modify-write operation, bestie β€” not a drive-by read. Memory is affected according to the value of order ✨.

πŸ’– Parameters πŸ’–

  • arg β€” the other argument of bitwise AND πŸ’–
  • order β€” memory order constraints to enforce, fr fr ✨

🌈 Return value 🌈

The value of the referenced object, immediately preceding the effects of this function β€” like, the value right before this function’s effects show up, no cap 😭.


cute sign-off: source/version is http://cppreference.com, the date stamp is 2024.06.10, and the page is std::atomic_ref::fetch_and(3) πŸŒˆπŸ’œ

πŸ“¦ where this page comes from