std::experi...k_ptr::load(3)
π NAME
std::experimental::atomic_weak_ptr::load β ok so this is the std::experimental::atomic_weak_ptr::load page, bestie, and it's literally the glow-up your weak_ptr needed β¨ (this is a cppreference.com joint, and yeah the title up top is the std::experi...k_ptr::load(3) one, we're not typing that whole thing out again π)
πΈ Synopsis
weak_ptr<T> load( std::memory_order order = std::memory_order_seq_cst ) const
noexcept;
So what does it do? It atomically loads and returns the current value of the atomic_weak_ptr. That's the whole vibe. Memory is affected according to the value of order β like, the order you pass in decides how the memory party gets synced πͺ©
β οΈ Okay so this is the important part, do not skip:ordermust be one ofstd::memory_order_relaxed,std::memory_order_consume,std::memory_order_acquireorstd::memory_order_seq_cst. Anything else? Behavior is undefined. Not "kinda weird", not "probably fine" β undefined, fr fr, so don't be cute with it π
π§ Parameters
orderβ the memory order constraints to enforce π (like, which rules the memory ops have to play by)
π¦ Remarks
All associated use_count increments are guaranteed to be performed as part of the atomic operation. Iconic. No half-done counter business, it's all one atomic package deal π«Ά
β Return value
The current value of the atomic_weak_ptr. That's it, that's the tea π
π See also
operator weak_ptr<T>β loads a value from an atomic object (public member function)std::atomic_is_lock_free(std::shared_ptr)std::atomic_load(std::shared_ptr)std::atomic_load_explicit(std::shared_ptr)std::atomic_store(std::shared_ptr)std::atomic_store_explicit(std::shared_ptr)std::atomic_exchange(std::shared_ptr)std::atomic_exchange_explicit(std::shared_ptr)std::atomic_compare_exchange_weak(std::shared_ptr)std::atomic_compare_exchange_strong(std::shared_ptr)std::atomic_compare_exchange_weak_explicit(std::shared_ptr)std::atomic_compare_exchange_strong_explicit(std::shared_ptr)
That whole lineup above β that's the gang that specializes atomic operations for std::shared_ptr (function template) β¨ and heads up, some of that set is (deprecated in C++20) and (removed in C++26), so π check your standard version before you commit, iykyk.
kisses bestie!! π this whole thing is brought to you by http://cppreference.com and it's dated 2024.06.10 β go forth and lock-free responsibly, mwah ππ¦πΈ
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms