nit (here and for all other new operator<=>): perhaps better to be explicit about the std::strong_ordering return type? And perhaps making it constexpr while touching?
<details>
<summary>git diff on 48840bfc2d</summary>
diff --git a/src/prevector.h b/src/prevector.h
index d4d90c7350..595be4a603 100644
--- a/src/prevector.h
+++ b/src/prevector.h
@@ -7,6 +7,7 @@
#include <algorithm>
#include <cassert>
+#include <compare>
#include <cstddef>
#include <cstdint>
#include <cstdlib>
@@ -71,8 +72,8 @@ public:
iterator& operator+=(size_type n) { ptr += n; return *this; }
iterator operator-(size_type n) const { return iterator(ptr - n); }
iterator& operator-=(size_type n) { ptr -= n; return *this; }
- bool operator==(iterator x) const { return ptr == x.ptr; }
- auto operator<=>(iterator x) const { return ptr <=> x.ptr; }
+ constexpr bool operator==(iterator x) const { return ptr == x.ptr; }
+ constexpr std::strong_ordering operator<=>(iterator x) const { return ptr <=> x.ptr; }
};
class const_iterator {
@@ -99,8 +100,8 @@ public:
const_iterator& operator+=(size_type n) { ptr += n; return *this; }
const_iterator operator-(size_type n) const { return const_iterator(ptr - n); }
const_iterator& operator-=(size_type n) { ptr -= n; return *this; }
- bool operator==(const_iterator x) const { return ptr == x.ptr; }
- auto operator<=>(const_iterator x) const { return ptr <=> x.ptr; }
+ constexpr bool operator==(const_iterator x) const { return ptr == x.ptr; }
+ constexpr std::strong_ordering operator<=>(const_iterator x) const { return ptr <=> x.ptr; }
};
private:
diff --git a/src/script/script.h b/src/script/script.h
index b06be9c975..f1472a7dd3 100644
--- a/src/script/script.h
+++ b/src/script/script.h
@@ -14,6 +14,7 @@
#include <util/hash_type.h>
#include <cassert>
+#include <compare>
#include <cstdint>
#include <cstring>
#include <limits>
@@ -269,11 +270,11 @@ public:
m_value = set_vch(vch);
}
- inline bool operator==(const int64_t& rhs) const { return m_value == rhs; }
- inline auto operator<=>(const int64_t& rhs) const { return m_value <=> rhs; }
+ inline constexpr bool operator==(const int64_t& rhs) const { return m_value == rhs; }
+ inline constexpr std::strong_ordering operator<=>(const int64_t& rhs) const { return m_value <=> rhs; }
- inline bool operator==(const CScriptNum& rhs) const { return operator==(rhs.m_value); }
- inline auto operator<=>(const CScriptNum& rhs) const { return operator<=>(rhs.m_value); }
+ inline constexpr bool operator==(const CScriptNum& rhs) const { return operator==(rhs.m_value); }
+ inline constexpr std::strong_ordering operator<=>(const CScriptNum& rhs) const { return operator<=>(rhs.m_value); }
inline CScriptNum operator+( const int64_t& rhs) const { return CScriptNum(m_value + rhs);}
inline CScriptNum operator-( const int64_t& rhs) const { return CScriptNum(m_value - rhs);}
diff --git a/src/test/scriptnum10.h b/src/test/scriptnum10.h
index 402606714d..fd112d6ff7 100644
--- a/src/test/scriptnum10.h
+++ b/src/test/scriptnum10.h
@@ -7,6 +7,7 @@
#define BITCOIN_TEST_SCRIPTNUM10_H
#include <cassert>
+#include <compare>
#include <cstdint>
#include <limits>
#include <stdexcept>
@@ -60,11 +61,11 @@ public:
m_value = set_vch(vch);
}
- inline bool operator==(const int64_t& rhs) const { return m_value == rhs; }
- inline auto operator<=>(const int64_t& rhs) const { return m_value <=> rhs; }
+ inline constexpr bool operator==(const int64_t& rhs) const { return m_value == rhs; }
+ inline constexpr std::strong_ordering operator<=>(const int64_t& rhs) const { return m_value <=> rhs; }
- inline bool operator==(const CScriptNum10& rhs) const { return operator==(rhs.m_value); }
- inline auto operator<=>(const CScriptNum10& rhs) const { return operator<=>(rhs.m_value); }
+ inline constexpr bool operator==(const CScriptNum10& rhs) const { return operator==(rhs.m_value); }
+ inline constexpr std::strong_ordering operator<=>(const CScriptNum10& rhs) const { return operator<=>(rhs.m_value); }
inline CScriptNum10 operator+( const int64_t& rhs) const { return CScriptNum10(m_value + rhs);}
inline CScriptNum10 operator-( const int64_t& rhs) const { return CScriptNum10(m_value - rhs);}
diff --git a/src/util/bitdeque.h b/src/util/bitdeque.h
index 21934e02da..be3e0fd859 100644
--- a/src/util/bitdeque.h
+++ b/src/util/bitdeque.h
@@ -6,6 +6,7 @@
#define BITCOIN_UTIL_BITDEQUE_H
#include <bitset>
+#include <compare>
#include <cstddef>
#include <deque>
#include <limits>
@@ -99,8 +100,8 @@ class bitdeque
friend Iterator operator+(Iterator x, difference_type dist) { x += dist; return x; }
friend Iterator operator+(difference_type dist, Iterator x) { x += dist; return x; }
friend Iterator operator-(Iterator x, difference_type dist) { x -= dist; return x; }
- friend auto operator<=>(const Iterator& x, const Iterator& y) { return std::tie(x.m_it, x.m_bitpos) <=> std::tie(y.m_it, y.m_bitpos); }
- friend bool operator==(const Iterator& x, const Iterator& y) { return x.m_it == y.m_it && x.m_bitpos == y.m_bitpos; }
+ friend constexpr std::strong_ordering operator<=>(const Iterator& x, const Iterator& y) { return std::tie(x.m_it, x.m_bitpos) <=> std::tie(y.m_it, y.m_bitpos); }
+ friend constexpr bool operator==(const Iterator& x, const Iterator& y) { return x.m_it == y.m_it && x.m_bitpos == y.m_bitpos; }
reference operator*() const { return (*m_it)[m_bitpos]; }
reference operator[](difference_type pos) const { return *(*this + pos); }
};
</details>