std::atomic_ref::exchange(3)
β¨ std::atomic_ref::exchange β C++ Standard Libary β¨
okay so bestie, weβre in the C++ Standard Libary β yes, thatβs how the header spells it, donβt come for me π β and this page is all about std::atomic_ref::exchange(3). Itβs giving atomic read-modify-write realness and Iβm lowkey obsessed. π«Ά
πΈ NAME πΈ
std::atomic_ref::exchange - std::atomic_ref::exchange. Thatβs it. Thatβs the name. Yes, twice. Slay. π
β¨ Synopsis β¨
Hereβs the signature, copied exactly, including the (since C++20) marker chilling in the middle:
T exchange( T desired, std::memory_order order =
(since C++20)
std::memory_order_seq_cst ) const noexcept;
Atomically replaces the value of the referenced object with desired. The operation is a read-modify-write operation. Memory is affected according to the value of order. Thatβs the whole tea, and itβs honestly such a main character move. π
π Parameters π
desiredβ value to assign. Give it what you want the referenced object to become, bestie. πorderβ memory order constraints to enforce. This is the vibe check for how memory gets affected. β¨
π Return value π
The value of the referenced object before the call. So it hands you the old value on the way out β iconic behavior, no cap. π
Okay bye bestie β this page is from http://cppreference.com, dated 2024.06.10, and itβs std::atomic_ref::exchange(3) signing off. 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