std::atomic...re_explicit(3)

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

🫢 std::atomic...re_explicit(3) β€” C++ Standard Libary 🫢

okay so bestie, we are in the C++ Standard Libary manual (yes, that is literally how the header spells it, not me 😭), and this page is all about std::atomic_store and std::atomic_store_explicit. The manual name is std::atomic...re_explicit(3), and we are about to get so familiar with these atomic store girlies. πŸ’…


✨ NAME ✨

std::atomic_store,std::atomic_store_explicit - std::atomic_store,std::atomic_store_explicit


🌸 Synopsis 🌸

Defined in header <atomic>

  • (1) (since C++11)
template< class T >
void atomic_store( std::atomic<T>* obj,
                   typename std::atomic<T>::value_type desired ) noexcept;
  • (2) (since C++11)
template< class T >
void atomic_store( volatile std::atomic<T>* obj,
                   typename std::atomic<T>::value_type desired ) noexcept;
  • (3) (since C++11)
template< class T >
void atomic_store_explicit( std::atomic<T>* obj,
                            typename std::atomic<T>::value_type desired,
                            std::memory_order order ) noexcept;
  • (4) (since C++11)
template< class T >
void atomic_store_explicit( volatile std::atomic<T>* obj,
                            typename std::atomic<T>::value_type desired,
                            std::memory_order order ) noexcept;

1,2) Atomically replaces the value pointed to by obj with the value of desired as if by obj->store(desired).

3,4) Atomically replaces the value pointed to by obj with the value of desired as if by obj->store(desired, order).

⚠️ bestie, listen: if order is one of std::memory_order_consume, std::memory_order_acquire and std::memory_order_acq_rel, the behavior is undefined. Like, undefined behavior. Do not play with that. πŸ’€

πŸŽ€ Parameters πŸŽ€

  • obj β€” pointer to the atomic object to modify
  • desired β€” the value to store in the atomic object
  • order β€” the memory synchronization ordering

πŸ¦‹ Return value πŸ¦‹

(none)

literally nothing β€” it is giving void, no return, no takebacks. 🫢


πŸ’œ Defect reports πŸ’œ

The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

  • P0558R1 β€” applied to C++11.
    • Behavior as published: exact type match was required because T is only deduced.
    • Correct behavior: T was deduced from multiple arguments from obj.

🌈 See also 🌈

  • store β€” atomically replaces the value of the atomic object with a non-atomic argument (public member function of std::atomic<T>)
  • atomic_load (C++11) β€” atomically obtains the value stored in an atomic object (function template)
  • atomic_load_explicit (C++11) β€” atomically obtains the value stored in an atomic object (function template)
  • memory_order (C++11) β€” defines memory ordering constraints for the given atomic operation (enum)
  • std::atomic_store(std::shared_ptr) β€” specializes atomic operations for std::shared_ptr (function template; deprecated in C++20; removed in C++26)
  • std::atomic_store_explicit(std::shared_ptr) β€” specializes atomic operations for std::shared_ptr (function template; deprecated in C++20; removed in C++26)
  • C documentation for atomic_store, atomic_store_explicit

mwah πŸ’‹ that is the whole page, bestie. source/version: http://cppreference.com; date: 2024.06.10; manual: std::atomic...re_explicit(3). go be iconic with your atomics 🫢✨

πŸ“¦ where this page comes from