[libcxx-commits] [libcxx] [libc++] Move std::abs into __math/abs.h (PR #139586)
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Jun 15 09:05:15 PDT 2025
================
@@ -39,6 +39,30 @@ template <class _A1, __enable_if_t<is_integral<_A1>::value, int> = 0>
return __builtin_fabs((double)__x);
}
+// abs
+
+[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI inline float abs(float __x) _NOEXCEPT { return __builtin_fabsf(__x); }
+[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI inline double abs(double __x) _NOEXCEPT { return __builtin_fabs(__x); }
+
+[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI inline long double abs(long double __x) _NOEXCEPT {
+ return __builtin_fabsl(__x);
+}
+
+template <class = int>
----------------
philnik777 wrote:
We don't really change the priority. It shouldn't ever be user-observable. It's to make sure there is a preferred candidate between our version and the libcs version when they're both available, since we'd otherwise have a function redefinition. In no other circumstance does this change overload resolution AFAIK.
https://github.com/llvm/llvm-project/pull/139586
More information about the libcxx-commits
mailing list