std::atomic...ad_explicit(3)

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

πŸ’– NAME πŸ’–

std::atomic_load, std::atomic_load_explicit β€” hey bestie, welcome to the C++ Standard Libary manual page for these atomic-load icons. This is the std::atomic_load / std::atomic_load_explicit moment, and we’re gonna understand it fr fr. πŸ’…βœ¨

✨ Synopsis ✨

Defined in header <atomic>.

Here are all four overloads, labels and (since C++11) energy included β€” no skipping, no cap:

template< class T >                                           (1)
(since C++11)
T atomic_load( const std::atomic<T>* obj ) noexcept;

template< class T >                                           (2)
(since C++11)
T atomic_load( const volatile std::atomic<T>* obj ) noexcept;

template< class T >

T atomic_load_explicit( const std::atomic<T>* obj,            (3)
(since C++11)

                            std::memory_order order ) noexcept;
template< class T >

T atomic_load_explicit( const volatile std::atomic<T>* obj,   (4)
(since C++11)

                            std::memory_order order ) noexcept;

Okay so overloads (1) and (2) atomically obtain the value pointed to by obj as if by obj->load(). Slay. Overloads (3) and (4) atomically obtain the value pointed to by obj as if by obj->load(order). Big main-character energy. πŸ‘‘

⚠️ undefined behavior alert, bestie: if order is one of std::memory_order_release and std::memory_order_acq_rel, the behavior is undefined. Not a vibe. Do not do it. πŸ˜­πŸ’€

πŸŽ€ Parameters πŸŽ€

  • obj β€” pointer to the atomic object to modify.
  • order β€” the memory synchronization ordering for this operation.

🌸 Return value 🌸

The value that is held by the atomic object pointed to by obj. That’s the whole tea. πŸ’–

πŸ¦‹ See also πŸ¦‹

  • load β€” atomically obtains the value of the atomic object β€” public member function of std::atomic<T>.
  • 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).
  • memory_order β€” defines memory ordering constraints for the given atomic operation β€” (C++11) (enum).
  • std::atomic_load(std::shared_ptr) β€” specializes atomic operations for std::shared_ptr β€” (deprecated in C++20) (removed in C++26) (function template).
  • std::atomic_load_explicit(std::shared_ptr) β€” specializes atomic operations for std::shared_ptr β€” (deprecated in C++20) (removed in C++26) (function template).
  • C documentation for atomic_load, atomic_load_explicit β€” the C side of the story, iykyk.

source/version: http://cppreference.com Β· date: 2024.06.10 β€” bye bestie, go be the main character of atomic loads πŸ’…βœ¨πŸ«Ά

πŸ“¦ where this page comes from