Rebased ref, commits from common ancestor:
commit 17f470e4d617f6b8f2939900a95527323e520953
Author:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
AuthorDate: Mon Jun 2 09:45:51 2025 +0200
Commit:     Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
CommitDate: Mon Jun 2 11:46:29 2025 +0200

    use concepts
    
    Change-Id: I776ad35ad13c6952dbdb4d0336cada80ee3963bb

diff --git a/include/basegfx/numeric/ftools.hxx 
b/include/basegfx/numeric/ftools.hxx
index 8404dc2babcd..48033c81a0b0 100644
--- a/include/basegfx/numeric/ftools.hxx
+++ b/include/basegfx/numeric/ftools.hxx
@@ -23,6 +23,7 @@
 #include <cmath>
 #include <math.h>
 #include <basegfx/basegfxdllapi.h>
+#include <o3tl/concepts.hxx>
 #include <limits>
 #include <algorithm>
 
@@ -150,58 +151,58 @@ namespace basegfx
         inline double getSmallValue() { return 0.000000001f; }
 
         /// Compare against small value
-        template <typename T, std::enable_if_t<std::is_floating_point_v<T>, 
int> = 0>
-        inline bool equalZero(const T& rfVal)
+        template <o3tl::floating_point T>
+        inline constexpr bool equalZero(T rfVal)
         {
             return (fabs(rfVal) <= getSmallValue());
         }
 
         /// Compare against given small value
-        template <typename T, std::enable_if_t<std::is_floating_point_v<T>, 
int> = 0>
-        inline bool equalZero(const T& rfVal, const T& rfSmallValue)
+        template <o3tl::floating_point T>
+        inline constexpr bool equalZero(T rfVal, T rfSmallValue)
         {
             return (fabs(rfVal) <= rfSmallValue);
         }
 
-        template <typename T, std::enable_if_t<std::is_floating_point_v<T>, 
int> = 0>
-        inline bool equal(T const& rfValA, T const& rfValB)
+        template <o3tl::floating_point T>
+        inline constexpr bool equal(T rfValA, T rfValB)
         {
             // changed to approxEqual usage for better numerical correctness
             return rtl_math_approxEqual(rfValA, rfValB);
         }
 
-        template <typename T, std::enable_if_t<std::is_floating_point_v<T>, 
int> = 0>
-        inline bool equal(const T& rfValA, const T& rfValB, const T& 
rfSmallValue)
+        template <o3tl::floating_point T>
+        inline constexpr bool equal(T rfValA, T rfValB, T rfSmallValue)
         {
             return (fabs(rfValA - rfValB) <= rfSmallValue);
         }
 
-        template <typename T, std::enable_if_t<std::is_floating_point_v<T>, 
int> = 0>
-        inline bool less(const T& rfValA, const T& rfValB)
+        template <o3tl::floating_point T>
+        inline constexpr bool less(T rfValA, T rfValB)
         {
             return (rfValA < rfValB && !equal(rfValA, rfValB));
         }
 
-        template <typename T, std::enable_if_t<std::is_floating_point_v<T>, 
int> = 0>
-        inline bool lessOrEqual(const T& rfValA, const T& rfValB)
+        template <o3tl::floating_point T>
+        inline constexpr bool lessOrEqual(T rfValA, T rfValB)
         {
             return (rfValA < rfValB || equal(rfValA, rfValB));
         }
 
-        template <typename T, std::enable_if_t<std::is_floating_point_v<T>, 
int> = 0>
-        inline bool more(const T& rfValA, const T& rfValB)
+        template <o3tl::floating_point T>
+        inline constexpr bool more(T rfValA, T rfValB)
         {
             return (rfValA > rfValB && !equal(rfValA, rfValB));
         }
 
-        template <typename T, std::enable_if_t<std::is_floating_point_v<T>, 
int> = 0>
-        inline bool moreOrEqual(const T& rfValA, const T& rfValB)
+        template <o3tl::floating_point T>
+        inline constexpr bool moreOrEqual(T rfValA, T rfValB)
         {
             return (rfValA > rfValB || equal(rfValA, rfValB));
         }
 
-        template <typename T, std::enable_if_t<std::is_floating_point_v<T>, 
int> = 0>
-        inline bool betweenOrEqualEither(const T& rfValA, const T& rfValB, 
const T& rfValC)
+        template <o3tl::floating_point T>
+        inline constexpr bool betweenOrEqualEither(T rfValA, T rfValB, T 
rfValC)
         {
             return (rfValA > rfValB && rfValA < rfValC) || equal(rfValA, 
rfValB) || equal(rfValA, rfValC);
         }
diff --git a/include/o3tl/concepts.hxx b/include/o3tl/concepts.hxx
index 07ddcdc459ea..4510956d203a 100644
--- a/include/o3tl/concepts.hxx
+++ b/include/o3tl/concepts.hxx
@@ -50,6 +50,7 @@ namespace o3tl
 {
 template <typename T> concept type_32_bit = sizeof(T) == 4;
 template <typename T> concept type_64_bit = sizeof(T) == 8;
+template <typename T> concept arithmetic = std::is_arithmetic_v<T>;
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */
diff --git a/include/sax/tools/converter.hxx b/include/sax/tools/converter.hxx
index 6b18cac11bf4..9c4411f2a62e 100644
--- a/include/sax/tools/converter.hxx
+++ b/include/sax/tools/converter.hxx
@@ -29,6 +29,7 @@
 
 #include <rtl/strbuf.hxx>
 #include <sal/types.h>
+#include <o3tl/concepts.hxx>
 #include <rtl/ustrbuf.hxx>
 #include <com/sun/star/util/MeasureUnit.hpp>
 #include <tools/color.hxx>
@@ -316,7 +317,7 @@ public:
     static void convertBytesToHexBinary(OUStringBuffer& rBuffer, const void* 
pBytes,
                                         sal_Int32 nBytes);
 
-    template <typename T, std::enable_if_t<std::is_arithmetic_v<T>, int> = 0>
+    template <o3tl::arithmetic T>
     static void convertNumberToHexBinary(OUStringBuffer& rBuffer, T n)
     {
         convertBytesToHexBinary(rBuffer, &n, sizeof(n));
diff --git a/include/tools/XmlWriter.hxx b/include/tools/XmlWriter.hxx
index 9c8f82a86f42..6837483ca9ae 100644
--- a/include/tools/XmlWriter.hxx
+++ b/include/tools/XmlWriter.hxx
@@ -14,6 +14,7 @@
 
 #include <basegfx/numeric/ftools.hxx>
 #include <tools/toolsdllapi.h>
+#include <o3tl/concepts.hxx>
 #include <rtl/string.hxx>
 #include <memory>
 #include <string_view>
@@ -59,14 +60,15 @@ public:
     }
     void attribute(const char* sTagName, std::u16string_view aValue);
     void attribute(const char* sTagName, sal_Int64 aNumber);
-    template <typename T>
-    requires std::is_arithmetic_v<T> void attribute(const char* sTagName, T 
aNumber)
+
+    template <o3tl::arithmetic T> void attribute(const char* sTagName, T 
aNumber)
     {
         if constexpr (std::is_floating_point_v<T>)
             return attribute(sTagName, basegfx::fround64(aNumber));
         else
             return attribute(sTagName, static_cast<sal_Int64>(aNumber));
     }
+
     void attributeDouble(const char* sTagName, double aNumber);
     void attributeBase64(const char* sTagName, std::vector<sal_uInt8> const& 
rValueInBytes);
     void attributeBase64(const char* sTagName, std::vector<char> const& 
rValueInBytes);
diff --git a/include/tools/json_writer.hxx b/include/tools/json_writer.hxx
index 2977f7f8c231..6f173fc54f1e 100644
--- a/include/tools/json_writer.hxx
+++ b/include/tools/json_writer.hxx
@@ -11,6 +11,7 @@
 #include <sal/config.h>
 
 #include <tools/toolsdllapi.h>
+#include <o3tl/concepts.hxx>
 #include <rtl/string.hxx>
 #include <rtl/ustring.hxx>
 
@@ -63,8 +64,7 @@ public:
         put(pPropName, std::string_view(pPropVal, N));
     }
 
-    template <typename N, std::enable_if_t<std::is_arithmetic_v<N>, int> = 0>
-    void put(std::string_view pPropName, N n)
+    template <o3tl::arithmetic N> void put(std::string_view pPropName, N n)
     {
         putLiteral(pPropName, OString::number(n));
     }

Reply via email to