std::atomic::store(3)

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

πŸ’Ύ std::atomic::store(3) πŸ’Ύ

okay so welcome to the C++ Standard Libary manual, bestie β€” this page is std::atomic::store(3) and she is here to atomically replace stuff πŸ’…βœ¨


πŸŽ€ NAME πŸŽ€

std::atomic::store - std::atomic::store

(no cap, that's the whole name section, she's concise like that 🫢)


✨ Synopsis ✨

void store( T desired, std::memory_order order =
            std::memory_order_seq_cst ) noexcept;

Overload (1), since C++11 🌸

void store( T desired, std::memory_order order =
            std::memory_order_seq_cst ) volatile
noexcept;

Overload (2), since C++11 🌸

Atomically replaces the current value with desired. Memory is affected according to the value of order.

🚨 if order is one of std::memory_order_consume, std::memory_order_acquire and std::memory_order_acq_rel, the behavior is undefined. That's not a vibe, bestie β€” do not do it 😭
😭 Since C++20, it is deprecated if std::atomic<T>::is_always_lock_free is false and overload (2) participates in overload resolution. That's the caveat, fr fr.

🌸 Parameters 🌸

  • desired β€” the value to store into the atomic variable πŸ’–
  • order β€” memory order constraints to enforce πŸ‘‘

πŸ¦‹ Return value πŸ¦‹

(none) β€” literally no return value, she's not giving anything back and that's the point πŸ’…


πŸ‘‘ See also πŸ‘‘

  • operator= β€” stores a value into an atomic object (public member function)
  • atomic_store β€” atomically replaces the value of the atomic object with a non-atomic argument (C++11) (function template)
  • atomic_store_explicit β€” atomically replaces the value of the atomic object with a non-atomic argument (C++11) (function template)

source: http://cppreference.com Β· version/date: 2024.06.10 Β· page: std::atomic::store(3) β€” mwah, bye bestie πŸ«ΆπŸ’–

πŸ“¦ where this page comes from