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

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Fri Jun 26 09:56:20 PDT 2026


================
@@ -259,6 +261,77 @@ __cxx_atomic_fetch_xor(__cxx_atomic_base_impl<_Tp>* __a, _Tp __pattern, memory_o
       std::addressof(__a->__a_value), __pattern, static_cast<__memory_order_underlying_t>(__order));
 }
 
+// Clang's __c11_atomic_fetch_max/min builtins do not accept pointer
+// arguments, so dispatch to a CAS loop for pointer types.
+// TODO: Use the builtin for pointer types once Clang accepts them.
+template <class _Tp, __enable_if_t<!is_pointer<_Tp>::value, int> = 0>
----------------
ldionne wrote:

I purposefully used `enable_if` here because I didn't want to conditionalize this on a C++ version. In principle, this atomic support header could be used in any language mode (even though it isn't right now).

I'm not dead set on this, I don't care very strongly, but that was my rationale when writing it. If you think the readability gain is worth the conditional declaration, I can do that.

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


More information about the libcxx-commits mailing list