std::atomic::fetch_min(3)
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 ofstd::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β value202403L, std(C++26), featureAtomic 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
- 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