aboutsummaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/Cryptography/BigNumber.cpp2
-rw-r--r--src/common/Cryptography/BigNumber.h17
-rw-r--r--src/common/Debugging/WheatyExceptionReport.h8
-rw-r--r--src/common/Utilities/SmartEnum.h9
-rw-r--r--src/common/Utilities/TaskScheduler.h13
5 files changed, 22 insertions, 27 deletions
diff --git a/src/common/Cryptography/BigNumber.cpp b/src/common/Cryptography/BigNumber.cpp
index 6839cbc9255..b9f6a1c947c 100644
--- a/src/common/Cryptography/BigNumber.cpp
+++ b/src/common/Cryptography/BigNumber.cpp
@@ -132,7 +132,7 @@ BigNumber& BigNumber::operator<<=(int n)
return *this;
}
-int BigNumber::CompareTo(BigNumber const& bn) const
+int32 BigNumber::CompareTo(BigNumber const& bn) const
{
return BN_cmp(_bn, bn._bn);
}
diff --git a/src/common/Cryptography/BigNumber.h b/src/common/Cryptography/BigNumber.h
index e61a8073c31..d36c8a9f718 100644
--- a/src/common/Cryptography/BigNumber.h
+++ b/src/common/Cryptography/BigNumber.h
@@ -94,12 +94,17 @@ class TC_COMMON_API BigNumber
return t <<= n;
}
- int CompareTo(BigNumber const& bn) const;
- bool operator<=(BigNumber const& bn) const { return (CompareTo(bn) <= 0); }
- bool operator==(BigNumber const& bn) const { return (CompareTo(bn) == 0); }
- bool operator>=(BigNumber const& bn) const { return (CompareTo(bn) >= 0); }
- bool operator<(BigNumber const& bn) const { return (CompareTo(bn) < 0); }
- bool operator>(BigNumber const& bn) const { return (CompareTo(bn) > 0); }
+ int32 CompareTo(BigNumber const& bn) const;
+ bool operator==(BigNumber const& bn) const { return CompareTo(bn) == 0; }
+ std::strong_ordering operator<=>(BigNumber const& other) const
+ {
+ int32 cmp = CompareTo(other);
+ if (cmp < 0)
+ return std::strong_ordering::less;
+ if (cmp > 0)
+ return std::strong_ordering::greater;
+ return std::strong_ordering::equal;
+ }
bool IsZero() const;
bool IsNegative() const;
diff --git a/src/common/Debugging/WheatyExceptionReport.h b/src/common/Debugging/WheatyExceptionReport.h
index 2b99dcbb83c..b1876528a78 100644
--- a/src/common/Debugging/WheatyExceptionReport.h
+++ b/src/common/Debugging/WheatyExceptionReport.h
@@ -7,6 +7,7 @@
#include <winnt.h>
#include <winternl.h>
#include <dbghelp.h>
+#include <compare>
#include <set>
#include <cstdlib>
#include <cstdio>
@@ -101,11 +102,8 @@ struct SymbolPair
_offset = offset;
}
- bool operator<(SymbolPair const& other) const
- {
- return _offset < other._offset ||
- (_offset == other._offset && _type < other._type);
- }
+ bool operator==(SymbolPair const& other) const = default;
+ std::strong_ordering operator<=>(SymbolPair const& other) const = default;
DWORD _type;
DWORD_PTR _offset;
diff --git a/src/common/Utilities/SmartEnum.h b/src/common/Utilities/SmartEnum.h
index 24e3c60bd30..3c58d433406 100644
--- a/src/common/Utilities/SmartEnum.h
+++ b/src/common/Utilities/SmartEnum.h
@@ -85,13 +85,10 @@ class EnumUtils
Iterator() : _index(EnumUtils::Count<Enum>()) {}
explicit Iterator(size_t index) : _index(index) { }
- bool operator==(const Iterator& other) const { return other._index == _index; }
- bool operator!=(const Iterator& other) const { return !operator==(other); }
+ bool operator==(const Iterator& other) const = default;
+ std::strong_ordering operator<=>(const Iterator& other) const = default;
+
difference_type operator-(Iterator const& other) const { return _index - other._index; }
- bool operator<(const Iterator& other) const { return _index < other._index; }
- bool operator<=(const Iterator& other) const { return _index <= other._index; }
- bool operator>(const Iterator& other) const { return _index > other._index; }
- bool operator>=(const Iterator& other) const { return _index >= other._index; }
value_type operator[](difference_type d) const { return FromIndex<Enum>(_index + d); }
value_type operator*() const { return operator[](0); }
diff --git a/src/common/Utilities/TaskScheduler.h b/src/common/Utilities/TaskScheduler.h
index ee43a203a13..aee387ea46f 100644
--- a/src/common/Utilities/TaskScheduler.h
+++ b/src/common/Utilities/TaskScheduler.h
@@ -95,18 +95,13 @@ class TC_COMMON_API TaskScheduler
Task& operator= (Task&& right) = delete;
// Order tasks by its end
- inline bool operator< (Task const& other) const
+ std::weak_ordering operator<=> (Task const& other) const
{
- return _end < other._end;
- }
-
- inline bool operator> (Task const& other) const
- {
- return _end > other._end;
+ return _end <=> other._end;
}
// Compare tasks with its end
- inline bool operator== (Task const& other)
+ bool operator== (Task const& other) const
{
return _end == other._end;
}
@@ -126,7 +121,7 @@ class TC_COMMON_API TaskScheduler
bool operator() (TaskContainer const& left, TaskContainer const& right) const
{
return (*left.get()) < (*right.get());
- };
+ }
};
class TC_COMMON_API TaskQueue