std::atomic_ref::fetch_max(3)

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

πŸŽ€ std::atomic_ref::fetch_max(3) πŸŽ€

okay so bestie, this page is from the C++ Standard Libary manual β€” manual name folded in right here at the top, periodt. We're talking about std::atomic_ref::fetch_max, and the vibe is atomic maximum with zero chill. πŸ’…


πŸ’– NAME πŸ’–

std::atomic_ref::fetch_max β€” std::atomic_ref::fetch_max

yes, the name section said it twice. she's consistent, okay? 😭


✨ Synopsis ✨

      member only of atomic_ref<Integral > specializations
      T fetch_max( T arg, std::memory_order order =
                              std::memory_order_seq_cst ) const
   (1) (since C++26)
      noexcept;
      member only of atomic_ref<T*> partial specialization
      T* fetch_max( T* arg, std::memory_order order =
                                std::memory_order_seq_cst ) const
   (2) (since C++26)
      noexcept;

so what does it actually do, bestie? It atomically replaces the current value of the referenced object with the result of std::max of the value and arg. That is, it performs atomic maximum operation. The operation is a read-modify-write operation. Memory is affected according to the value of order.

⚠️ for overload 2): if the pointers point to different complete objects (or subobjects thereof), pointer comparison does not establish a strict weak ordering. that's the spicy caveat, bestie.

🌸 Parameters 🌸

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

πŸ¦‹ Return value πŸ¦‹

The value immediately preceding the effects of this function in the modification order of *this. that's what you get back, no cap. ✨


πŸ‘‘ Notes πŸ‘‘

feature-test macro tea β˜•:

  • Feature-test macro: __cpp_lib_atomic_min_max β€” Value: 202403L β€” Std: C++26 β€” Feature: Atomic minimum/maximum

πŸ“ Example πŸ“

This section is incomplete.

Reason: no example.

not me staring at an empty example section πŸ˜­πŸ™ˆ


🧚 Category 🧚

  • * Todo no example

mwah πŸ’‹ β€” source/version: http://cppreference.com, date: 2024.06.10, page: std::atomic_ref::fetch_max(3). that's the whole footer tea, folded into a cute little sign-off. 🫢

πŸ“¦ where this page comes from