std::experi...r::exchange(3)

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

🌸 NAME 🌸

okay so bestie, this is the C++ Standard Libary manual page for std::experimental::atomic_weak_ptr::exchange, and the NAME line is literally std::experimental::atomic_weak_ptr::exchange - std::experimental::atomic_weak_ptr::exchange β€” the repetition is iconic, we respect it. πŸ’– It's the atomic exchange situation for a weak pointer, and we're gonna get through every detail together, no cap.

πŸ¦‹ Synopsis πŸ¦‹

weak_ptr<T> exchange( weak_ptr<T> desired, std::memory_order order =
std::memory_order_seq_cst ) noexcept;

This atomically replaces the underlying weak_ptr with desired. The operation is a read-modify-write operation. Memory is affected according to the value of order. Slay. ✨

πŸŽ€ Parameters πŸŽ€

  • desired β€” value to assign. literally the new value going in. πŸ’…
  • order β€” memory order constraints to enforce. yes bestie, the memory-order vibe check. πŸŒ€

🌟 Return value 🌟

The value of the atomic variable before the call. so you get the old value back, periodt. 🫢

πŸ’… Remarks πŸ’…

  • All changes to the atomic_weak_ptr object itself, and all associated use_count increments, are guaranteed to be performed atomically. πŸ”₯
  • Associated use_count decrements take place after the atomic operation, but are not required to be part of it. πŸ’€
  • Any associated destruction or deallocation operations take place after the atomic operation and are not part of it. 🌈

πŸ’œ See also πŸ’œ

the see-also crew, all present and accounted for:

  • 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)

Also in the see-also zone, verbatim: specializes atomic operations for std::shared_ptr, (function template), (deprecated in C++20), (removed in C++26). The deprecated/removed tags are real caveats, bestie β€” don't ignore them. πŸ‘‘


signing off with source http://cppreference.com, version/date 2024.06.10, and page std::experi...r::exchange(3) β€” bye bestie, go be atomic πŸ’–πŸ¦‹

πŸ“¦ where this page comes from