]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
isinf: Make more C++ safe.
authorBruno Haible <bruno@clisp.org>
Tue, 3 Feb 2026 09:46:27 +0000 (10:46 +0100)
committerBruno Haible <bruno@clisp.org>
Tue, 3 Feb 2026 09:46:27 +0000 (10:46 +0100)
* lib/math.in.h (isinf): In C++ mode, define as a template with three
instantiations, instead of as a macro.

ChangeLog
lib/math.in.h

index 7d9831f49d3e33e899b9d35c437cdb40f8a918ae..f7874afd1fafe8b7608da6c01a71fd42265ac54b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2026-02-03  Bruno Haible  <bruno@clisp.org>
+
+       isinf: Make more C++ safe.
+       * lib/math.in.h (isinf): In C++ mode, define as a template with three
+       instantiations, instead of as a macro.
+
 2026-02-02  Bruno Haible  <bruno@clisp.org>
 
        isinf: Avoid unnecessary override of isinf().
index 210ac99cf3e858a231da1f0f8254ecc863476ad9..357b68e31d9189323d37398c491c7b6ee3908a13 100644 (file)
@@ -2508,11 +2508,18 @@ _GL_WARN_REAL_FLOATING_DECL (isfinite);
 _GL_EXTERN_C int gl_isinff (float x);
 _GL_EXTERN_C int gl_isinfd (double x);
 _GL_EXTERN_C int gl_isinfl (long double x);
-#  undef isinf
-#  define isinf(x) \
-   (sizeof (x) == sizeof (long double) ? gl_isinfl (x) : \
-    sizeof (x) == sizeof (double) ? gl_isinfd (x) : \
-    gl_isinff (x))
+#  ifdef __cplusplus
+template <typename T> int isinf (T);
+template <> inline int isinf<float> (float x) { return gl_isinff (x); }
+template <> inline int isinf<double> (double x) { return gl_isinfd (x); }
+template <> inline int isinf<long double> (long double x) { return gl_isinfl (x); }
+#  else
+#   undef isinf
+#   define isinf(x) \
+      (sizeof (x) == sizeof (long double) ? gl_isinfl (x) : \
+       sizeof (x) == sizeof (double) ? gl_isinfd (x) : \
+       gl_isinff (x))
+#  endif
 # endif
 # if @GNULIB_ISINF@ && defined __cplusplus
 #  if defined isinf || defined GNULIB_NAMESPACE