[libcxx-commits] [libcxx] [libc++] Implement P0493R5: Atomic minimum/maximum (PR #180333)

A. Jiang via libcxx-commits libcxx-commits at lists.llvm.org
Tue Feb 24 02:43:01 PST 2026


================
@@ -377,6 +403,32 @@ struct atomic_ref<_Tp*> : public __atomic_ref_base<_Tp*> {
   _LIBCPP_HIDE_FROM_ABI _Tp* fetch_sub(ptrdiff_t __arg, memory_order __order = memory_order_seq_cst) const noexcept {
     return __atomic_fetch_sub(this->__ptr_, __arg * sizeof(_Tp), std::__to_gcc_order(__order));
   }
+#  if _LIBCPP_STD_VER >= 26
+  _LIBCPP_HIDE_FROM_ABI _Tp* fetch_max(_Tp* __arg, memory_order __order = memory_order_seq_cst) const noexcept {
+#    if __has_builtin(__atomic_fetch_max)
+    return __atomic_fetch_max(this->__ptr_, __arg * sizeof(_Tp), std::__to_gcc_order(__order));
----------------
frederick-vs-ja wrote:

Looks like copy-pasta to me.
```suggestion
    return __atomic_fetch_max(this->__ptr_, __arg, std::__to_gcc_order(__order));
```

https://github.com/llvm/llvm-project/pull/180333


More information about the libcxx-commits mailing list