std::atomic::fetch_min(3)

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

okay bestie, welcome to the std::atomic::fetch_min(3) page from the C++ Standard Libary πŸ’– β€” yes, that spelling is staying, it’s part of the lore now. We’re talking about std::atomic::fetch_min, and it’s lowkey exactly what it sounds like.

🌸 NAME 🌸

std::atomic::fetch_min β€” std::atomic::fetch_min. periodt. that’s the name, that’s the function, no notes. πŸ’…

✨ Synopsis ✨

okay so here’s the whole lineup, bestie β€” all of these are since C++26 πŸŽ€

member only of atomic<Integral > specializations

(1) (since C++26)
T fetch_min( T arg, std::memory_order order =
             std::memory_order_seq_cst ) noexcept;

(2) (since C++26)
T fetch_min( T arg, std::memory_order order =
             std::memory_order_seq_cst ) volatile noexcept;

member only of atomic<T*> partial specialization

(3) (since C++26)
T* fetch_min( T* arg, std::memory_order order =
              std::memory_order_seq_cst ) noexcept;

(4) (since C++26)
T* fetch_min( T* arg, std::memory_order order =
              std::memory_order_seq_cst ) volatile noexcept;

so basically (1) and (2) are members only of atomic<Integral > specializations, and (3) and (4) are members only of the atomic<T*> partial specialization. The volatile girlies are (2) and (4), and yes they’re noexcept β€” iconic behavior. ✨

Atomically replaces the current value with the result of std::min of the value and arg. That is, it performs atomic minimum operation. The operation is a read-modify-write operation. Memory is affected according to the value of order. πŸ¦‹

3,4) If the pointers point to different complete objects (or subobjects thereof), pointer comparison does not establish a strict weak ordering.

⚠️ πŸ’€ It is deprecated if std::atomic<T>::is_always_lock_free is false and overload (2) or (4) participates in overload resolution. That’s a real caveat, bestie β€” not a vibe.

🌈 Parameters 🌈

  • arg β€” the other argument of std::min.
  • order β€” memory order constraints to enforce.

πŸŽ€ Return value πŸŽ€

The value immediately preceding the effects of this function in the modification order of *this. πŸ’–

🧚 Notes 🧚

Feature-test macro check, because we love receipts:

  • __cpp_lib_atomic_min_max β€” value 202403L, std (C++26), feature Atomic minimum/maximum.

🌸 Example 🌸

This section is incomplete. Reason: no example.

πŸ‘‘ Category πŸ‘‘

  • Todo no example

okay that’s the whole page, bestie 🫢 source/version: http://cppreference.com; date: 2024.06.10; page: std::atomic::fetch_min(3). mwah πŸ’‹

πŸ“¦ where this page comes from