std::atomic::load(3)

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

πŸŽ€ NAME πŸŽ€

okay so bestie, this is the std::atomic::load page from the C++ Standard Libary manual β€” yes, that's the manual name up top, and we're folding it in here instead of copy-pasting the whole header line. The name is literally std::atomic::load, and the one-line description is also std::atomic::load. That's the whole name. πŸ’…

✨ Synopsis ✨

The signatures, copied exactly so nobody comes for me:

          T load( std::memory_order order
       (1) (since C++11)
                      = std::memory_order_seq_cst ) const noexcept;
          T load( std::memory_order order
       (2) (since C++11)
                      = std::memory_order_seq_cst ) const volatile noexcept;

So both overloads are (since C++11), both take a std::memory_order order that defaults to std::memory_order_seq_cst, overload (1) is const noexcept, and overload (2) is const volatile noexcept. Slay. ✨

What it does: it atomically loads and returns the current value of the atomic variable. Memory is affected according to the value of order. That's the whole vibe.

⚠️ warning bestie: if order is one of std::memory_order_release and std::memory_order_acq_rel, the behavior is undefined. Not "maybe weird" β€” undefined. Do not do it. πŸ’€

Also, it is deprecated if std::atomic<T>::is_always_lock_free is false and (since C++20) overload (2) participates in overload resolution. So that combo is giving deprecated energy. 🫠

πŸ’– Parameters πŸ’–

  • order β€” memory order constraints to enforce. That's it. That's the parameter. πŸŽ€

πŸ¦‹ Return value πŸ¦‹

The current value of the atomic variable. Periodt. πŸ’–

🌈 See also 🌈

  • operator T β€” loads a value from an atomic object (public member function)
  • atomic_load β€” (C++11)
  • atomic_load_explicit β€” atomically obtains the value stored in an atomic object (function template) (C++11)

mwah πŸ’‹ β€” source: http://cppreference.com, version/date: 2024.06.10, page: std::atomic::load(3). byeee πŸ¦‹

πŸ“¦ where this page comes from