include/i18nlangtag/lang.h  |    4 +--
 include/o3tl/strong_int.hxx |   53 ++++----------------------------------------
 2 files changed, 8 insertions(+), 49 deletions(-)

New commits:
commit 6bacbcaa102cb1bea56462fe8228c5387bbf8bdc
Author:     Mike Kaganski <[email protected]>
AuthorDate: Mon Dec 1 11:17:43 2025 +0100
Commit:     Mike Kaganski <[email protected]>
CommitDate: Thu Dec 4 11:03:34 2025 +0100

    Don't pass 16-bit value by const reference
    
    Change-Id: Ia9245ff724a081f5f908ccadb924ab8faf022211
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194872
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <[email protected]>

diff --git a/include/i18nlangtag/lang.h b/include/i18nlangtag/lang.h
index e04bdb13328e..5fbb7a65b53a 100644
--- a/include/i18nlangtag/lang.h
+++ b/include/i18nlangtag/lang.h
@@ -86,7 +86,7 @@
 #include <ostream>
 
 typedef o3tl::strong_int<sal_uInt16, struct LanguageTypeTag> LanguageType;
-inline std::ostream& operator<<(std::ostream& os, LanguageType const & lt) { 
os << sal_uInt16(lt); return os; }
+inline std::ostream& operator<<(std::ostream& os, LanguageType lt) { return os 
<< sal_uInt16(lt); }
 constexpr LanguageType primary(LanguageType lt) { return 
LanguageType(sal_uInt16(lt) & 0x03ff); }
 
 namespace o3tl
commit 61dcf1283c3293629b041dcd4a4e6dcb4c049397
Author:     Mike Kaganski <[email protected]>
AuthorDate: Mon Dec 1 09:47:51 2025 +0100
Commit:     Mike Kaganski <[email protected]>
CommitDate: Thu Dec 4 11:03:27 2025 +0100

    Simplify o3tl::strong_int ctor using concepts
    
    Change-Id: Iaee67cb3787c26a56bfa69764d9c5d138c4e4d56
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194854
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <[email protected]>

diff --git a/include/i18nlangtag/lang.h b/include/i18nlangtag/lang.h
index 7672cf85582f..e04bdb13328e 100644
--- a/include/i18nlangtag/lang.h
+++ b/include/i18nlangtag/lang.h
@@ -98,7 +98,7 @@ namespace o3tl
     // delete "sal_Int16" constructor via specialization: values > 0x7FFF are
     // actually used, and unfortunately passed around in the API as signed
     // "short", so use this to find all places where casts must be inserted
-    template<> template<> constexpr strong_int<unsigned 
short,LanguageTypeTag>::strong_int(short, 
std::enable_if<std::is_integral<short>::value, int>::type) = delete;
+    template<> template<> constexpr strong_int<unsigned 
short,LanguageTypeTag>::strong_int(short) = delete;
 #endif
 }
 
diff --git a/include/o3tl/strong_int.hxx b/include/o3tl/strong_int.hxx
index 4b1a108ee5b2..9bfc9c22f802 100644
--- a/include/o3tl/strong_int.hxx
+++ b/include/o3tl/strong_int.hxx
@@ -25,6 +25,7 @@
 #include <cassert>
 #include <type_traits>
 #include <compare>
+#include <concepts>
 #include <config_options.h>
 
 #include <o3tl/safeint.hxx>
@@ -56,10 +57,8 @@ public:
     explicit constexpr strong_int(int value) : m_value(value) {}
     explicit constexpr strong_int(unsigned int value) : m_value(value) {}
 #else
-    template<typename T> explicit constexpr strong_int(
-        T value,
-        typename std::enable_if<std::is_integral<T>::value, int>::type = 0):
-        m_value(value)
+    template <std::integral I> explicit constexpr strong_int(I value)
+        : m_value(value)
     {
         // catch attempts to pass in out-of-range values early
         assert(ValidRange<UNDERLYING_TYPE>::isInside(value) && "out of range");
commit f42ecf8c8214316164011b2c8b6cd901f254c7ff
Author:     Mike Kaganski <[email protected]>
AuthorDate: Thu Dec 4 05:59:16 2025 +0100
Commit:     Mike Kaganski <[email protected]>
CommitDate: Thu Dec 4 11:03:20 2025 +0100

    Simplify assertion in o3tl::strong_int ctor using o3tl::ValidRange
    
    Change-Id: I439531ae27eca791baca3c275738f29cfffaf418
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194971
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <[email protected]>

diff --git a/include/o3tl/strong_int.hxx b/include/o3tl/strong_int.hxx
index 5da4a913aabf..4b1a108ee5b2 100644
--- a/include/o3tl/strong_int.hxx
+++ b/include/o3tl/strong_int.hxx
@@ -27,50 +27,11 @@
 #include <compare>
 #include <config_options.h>
 
+#include <o3tl/safeint.hxx>
+
 namespace o3tl
 {
 
-#if !defined(__COVERITY__) || __COVERITY_MAJOR__ > 2024
-
-namespace detail {
-
-template<typename T1, typename T2> constexpr
-typename std::enable_if<
-    std::is_signed<T1>::value && std::is_signed<T2>::value, bool>::type
-isInRange(T2 value) {
-    return value >= std::numeric_limits<T1>::min()
-        && value <= std::numeric_limits<T1>::max();
-}
-
-template<typename T1, typename T2> constexpr
-typename std::enable_if<
-    std::is_signed<T1>::value && std::is_unsigned<T2>::value, bool>::type
-isInRange(T2 value) {
-    return value
-        <= static_cast<typename std::make_unsigned<T1>::type>(
-            std::numeric_limits<T1>::max());
-}
-
-template<typename T1, typename T2> constexpr
-typename std::enable_if<
-    std::is_unsigned<T1>::value && std::is_signed<T2>::value, bool>::type
-isInRange(T2 value) {
-    return value >= 0
-        && (static_cast<typename std::make_unsigned<T2>::type>(value)
-            <= std::numeric_limits<T1>::max());
-}
-
-template<typename T1, typename T2> constexpr
-typename std::enable_if<
-    std::is_unsigned<T1>::value && std::is_unsigned<T2>::value, bool>::type
-isInRange(T2 value) {
-    return value <= std::numeric_limits<T1>::max();
-}
-
-}
-
-#endif
-
 ///
 /// Wrap up an integer type so that we prevent accidental conversion to other 
integer types.
 ///
@@ -101,8 +62,7 @@ public:
         m_value(value)
     {
         // catch attempts to pass in out-of-range values early
-        assert(detail::isInRange<UNDERLYING_TYPE>(value)
-               && "out of range");
+        assert(ValidRange<UNDERLYING_TYPE>::isInside(value) && "out of range");
     }
 #endif
     strong_int() : m_value(0) {}

Reply via email to