std::atomic...ax_explicit(3)
π
std::atomic_fetch_max, std::atomic_fetch_max_explicit π
C++ Standard Libary Β· page std::atomic...ax_explicit(3) Β· okay bestie, weβre doing atomic max energy today β¨
π NAME π
std::atomic_fetch_max,std::atomic_fetch_max_explicit - std::atomic_fetch_max,std::atomic_fetch_max_explicit
Thatβs the whole name, no cap: two functions, one maxy atomic moment π«Ά
β¨ Synopsis β¨
Defined in header <atomic>:
Defined in header <atomic>
template< class T >
T atomic_fetch_max( std::atomic<T>* obj,
(1) (since C++26)
typename std::atomic<T>::value_type arg )
noexcept;
template< class T >
T atomic_fetch_max( volatile std::atomic<T>* obj,
(2) (since C++26)
typename std::atomic<T>::value_type arg )
noexcept;
template< class T >
T atomic_fetch_max_explicit( std::atomic<T>* obj,
typename std::atomic<T>::value_type
(3) (since C++26)
arg,
std::memory_order order ) noexcept;
template< class T >
T atomic_fetch_max_explicit( volatile std::atomic<T>* obj,
typename std::atomic<T>::value_type
(4) (since C++26)
arg,
std::memory_order order ) noexcept;
So hereβs the vibe: it atomically replaces the value pointed to by obj with the result of std::max between the old value of obj and arg. Then it returns the value obj held previously. The operation is performed as if this was executed:
1,2) obj->fetch_max(arg)
3,4) obj->fetch_max(arg, order)
Bestie, warning time: ifstd::atomic<T>has nofetch_maxmember (this member is only provided for integral and pointer types exceptbool), the program is ill-formed. Thatβs a hard no, not a cute little oopsie π
π Parameters π
objβ pointer to the atomic object to modifyargβ the value tostd::maxwith the value stored in the atomic objectorderβ the memory synchronization ordering
π«Ά Return value π«Ά
The value immediately preceding the effects of this function in the modification order of *obj. Slay, thatβs the return value π
π§ Notes π§
Feature-test macro tea β:
__cpp_lib_atomic_min_maxβ value202403L; Std(C++26); featureAtomic minimum/maximum
π Example π
This section is incomplete.
Reason: no example.
Itβs giving βplaceholder era,β bestie β no example yet π
π See also π
fetch_max(C++26) β atomically performsstd::maxbetween the argument and the value of the atomic object and obtains the value held previously (public member function ofstd::atomic<T>)atomic_fetch_min,atomic_fetch_min_explicit(C++26) β replaces the atomic object with the result ofstd::minwith a non-atomic argument and obtains the previous value of the atomic (function template)
π Category π
* Todo no example
okay bye bestie β this pageβs source/version/date footer energy is http://cppreference.com, 2024.06.10, page std::atomic...ax_explicit(3) πβ¨π¦
π¦ 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