[libcxx-commits] [libcxx] [libc++][math] Define overloads as templates (PR #108282)

Robin Caloudis via libcxx-commits libcxx-commits at lists.llvm.org
Wed Sep 11 12:51:07 PDT 2024


https://github.com/robincaloudis created https://github.com/llvm/llvm-project/pull/108282

**This is an experimental PR**. 

Not sure if this actually works.

>From 9a0e090c159539e2dc8fe66da8f8a4f09a3a5540 Mon Sep 17 00:00:00 2001
From: Robin Caloudis <robin.caloudis at gmx.de>
Date: Wed, 11 Sep 2024 21:47:53 +0200
Subject: [PATCH] Define overloads as templates

---
 libcxx/include/__math/traits.h | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/libcxx/include/__math/traits.h b/libcxx/include/__math/traits.h
index 3d4f14fc9cd552..c39ff16b5bbc07 100644
--- a/libcxx/include/__math/traits.h
+++ b/libcxx/include/__math/traits.h
@@ -79,12 +79,8 @@ _LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI boo
   return __builtin_isinf(__x);
 }
 
-_LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI
-#ifdef _LIBCPP_PREFERRED_OVERLOAD
-_LIBCPP_PREFERRED_OVERLOAD
-#endif
-    bool
-    isinf(double __x) _NOEXCEPT {
+template <class = void>
+_LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isinf(double __x) _NOEXCEPT {
   return __builtin_isinf(__x);
 }
 
@@ -103,12 +99,8 @@ _LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI boo
   return __builtin_isnan(__x);
 }
 
-_LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI
-#ifdef _LIBCPP_PREFERRED_OVERLOAD
-_LIBCPP_PREFERRED_OVERLOAD
-#endif
-    bool
-    isnan(double __x) _NOEXCEPT {
+template <class = void>
+_LIBCPP_NODISCARD inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool isnan(double __x) _NOEXCEPT {
   return __builtin_isnan(__x);
 }
 



More information about the libcxx-commits mailing list