include/comphelper/errcode.hxx |    8 ++------
 include/o3tl/strong_int.hxx    |    9 +++------
 2 files changed, 5 insertions(+), 12 deletions(-)

New commits:
commit 6227fccce44e7c44a7a6da707f361b1d4886c1d0
Author:     RMZeroFour <[email protected]>
AuthorDate: Sun Mar 24 18:57:55 2024 +0530
Commit:     Mike Kaganski <[email protected]>
CommitDate: Mon Mar 25 13:51:21 2024 +0100

    tdf#157665 Use <=> operator for errcode and strong_int
    
    As part of the efforts in #157665 concerning the spaceship operator
    for the C++20 codebase upgrade, this commit implements the spaceship
    operator, replacing redundant operator overloads, in strong_int.hxx
    and errcode.hxx
    
    Change-Id: I23985207c27d6a5147c3f7b4a0d2416f86dec5b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165219
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <[email protected]>

diff --git a/include/comphelper/errcode.hxx b/include/comphelper/errcode.hxx
index 000f2c761da9..31c4457db4b5 100644
--- a/include/comphelper/errcode.hxx
+++ b/include/comphelper/errcode.hxx
@@ -24,6 +24,7 @@
 #include <ostream>
 #include <o3tl/typed_flags_set.hxx>
 #include <optional>
+#include <compare>
 
 #if defined(DBG_UTIL)
 #if __has_include(<version>)
@@ -94,12 +95,7 @@ public:
     explicit operator sal_uInt32() const { return m_value; }
     explicit operator bool() const { return m_value != 0; }
 
-    bool operator<(ErrCode const & other) const { return m_value < 
other.m_value; }
-    bool operator<=(ErrCode const & other) const { return m_value <= 
other.m_value; }
-    bool operator>(ErrCode const & other) const { return m_value > 
other.m_value; }
-    bool operator>=(ErrCode const & other) const { return m_value >= 
other.m_value; }
-    bool operator==(ErrCode const & other) const { return m_value == 
other.m_value; }
-    bool operator!=(ErrCode const & other) const { return m_value != 
other.m_value; }
+    auto operator<=>(ErrCode const & other) const = default;
 
     /** convert to ERRCODE_NONE if it's a warning, else return the error */
     ErrCode IgnoreWarning() const {
diff --git a/include/o3tl/strong_int.hxx b/include/o3tl/strong_int.hxx
index 82107955897f..fd7a9abb9c52 100644
--- a/include/o3tl/strong_int.hxx
+++ b/include/o3tl/strong_int.hxx
@@ -24,6 +24,7 @@
 #include <limits>
 #include <cassert>
 #include <type_traits>
+#include <compare>
 
 namespace o3tl
 {
@@ -100,12 +101,8 @@ public:
     explicit operator bool() const { return m_value != 0; }
     UNDERLYING_TYPE get() const { return m_value; }
 
-    bool operator<(strong_int const & other) const { return m_value < 
other.m_value; }
-    bool operator<=(strong_int const & other) const { return m_value <= 
other.m_value; }
-    bool operator>(strong_int const & other) const { return m_value > 
other.m_value; }
-    bool operator>=(strong_int const & other) const { return m_value >= 
other.m_value; }
-    bool operator==(strong_int const & other) const { return m_value == 
other.m_value; }
-    bool operator!=(strong_int const & other) const { return m_value != 
other.m_value; }
+    auto operator<=>(strong_int const & other) const = default;
+
     strong_int& operator++() { ++m_value; return *this; }
     strong_int operator++(int) { UNDERLYING_TYPE nOldValue = m_value; 
++m_value; return strong_int(nOldValue); }
     strong_int& operator--() { --m_value; return *this; }

Reply via email to