[libcxx-commits] [libcxx] [libc++] Implement P0493R5: Atomic minimum/maximum (PR #180333)
via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Jun 28 06:32:40 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>
----------------
huixie90 wrote:
I don't have any preference over two overloads or `if constexpr`. The only reason I suggested the concept (as in the concept defined in the godbolt link) is that, it purely relies on the clang's Sema. if one day clang adds the support pointer fetch min/max, we don't need to change any code here as the concept will detect it
https://github.com/llvm/llvm-project/pull/180333
More information about the libcxx-commits
mailing list