std::atomic...ator&=,|=,^=(3)

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

✨ NAME ✨

okay so bestie, welcome to the std::atomic...ator&=,|=,^=(3) manual page from the C++ Standard Libary πŸ’… this one is all about std::atomic::operator&=,|=,^= β€” yes, the name is literally std::atomic::operator&=,|=,^= on both sides of the dash, and honestly? iconic. πŸŽ€


🌸 Synopsis 🌸

This is member only of atomic<Integral > specializations, so keep that in mind before you try to make it do something it is not supposed to do, bestie. 🫢

          member only of atomic<Integral > specializations
          T operator&=( T arg ) noexcept;                   (1) (since C++11)
          T operator&=( T arg ) volatile noexcept;          (2) (since C++11)
          T operator|=( T arg ) noexcept;                   (3) (since C++11)
          T operator|=( T arg ) volatile noexcept;          (4) (since C++11)
          T operator^=( T arg ) noexcept;                   (5) (since C++11)
          T operator^=( T arg ) volatile noexcept;          (6) (since C++11)

Atomically replaces the current value with the result of computation involving the previous value and arg. The operation is a read-modify-write operation. πŸ”₯

  • operator&= performs atomic bitwise and. Equivalent to return fetch_and(arg) & arg;.
  • operator|= performs atomic bitwise or. Equivalent to return fetch_or(arg) | arg;.
  • operator^= performs atomic bitwise exclusive or. Equivalent to return fetch_xor(arg) ^ arg;.
⚠️ it is deprecated if std::atomic<T>::is_always_lock_free is false and (since C++20) any volatile overload participates in overload resolution. like, that's the rule, no cap. πŸ’€

πŸ“ Parameters πŸ“

  • arg β€” the argument for the arithmetic operation

πŸ’– Return value πŸ’–

The resulting value (that is, the result of applying the corresponding binary operator to the value immediately preceding the effects of the corresponding member function in the modification order of *this). ✨


πŸ¦‹ Notes πŸ¦‹

Unlike most compound assignment operators, the compound assignment operators for atomic types do not return a reference to their left-hand arguments. They return a copy of the stored value instead. yep, that's the vibe check, and it passed. πŸ’…


πŸ‘€ See also πŸ‘€

  • fetch_and β€” atomically performs bitwise AND between the argument and the value of the atomic object and obtains the value held previously (public member function)
  • fetch_or β€” atomically performs bitwise OR between the argument and the value of the atomic object and obtains the value held previously (public member function)
  • 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)
  • operator++, operator++(int), operator--, operator--(int) β€” increments or decrements the atomic value by one (public member function)
  • operator+=, operator-= β€” adds to or subtracts from the atomic value (public member function)

and that's the page, bestie πŸ§šπŸ’œ shoutout to the footer: source is http://cppreference.com, date/version is 2024.06.10, and the manual tag is std::atomic...ator&=,|=,^=(3) β€” slay, bye! 🌈⭐

πŸ“¦ where this page comes from