treewide: use defaulted operator!=() and operator==()

in C++20, compiler generate operator!=() if the corresponding
operator==() is already defined, the language now understands
that the comparison is symmetric in the new standard.

fortunately, our operator!=() is always equivalent to
`! operator==()`, this matches the behavior of the default
generated operator!=(). so, in this change, all `operator!=`
are removed.

in addition to the defaulted operator!=, C++20 also brings to us
the defaulted operator==() -- it is able to generated the
operator==() if the member-wise lexicographical comparison.
under some circumstances, this is exactly what we need. so,
in this change, if the operator==() is also implemented as
a lexicographical comparison of all memeber variables of the
class/struct in question, it is implemented using the default
generated one by removing its body and mark the function as
`default`. moreover, if the class happen to have other comparison
operators which are implemented using lexicographical comparison,
the default generated `operator<=>` is used in place of
the defaulted `operator==`.

sometimes, we fail to mark the operator== with the `const`
specifier, in this change, to fulfil the need of C++ standard,
and to be more correct, the `const` specifier is added.

also, to generate the defaulted operator==, the operand should
be `const class_name&`, but it is not always the case, in the
class of `version`, we use `version` as the parameter type, to
fulfill the need of the C++ standard, the parameter type is
changed to `const version&` instead. this does not change
the semantic of the comparison operator. and is a more idiomatic
way to pass non-trivial struct as function parameters.

please note, because in C++20, both operator= and operator<=> are
symmetric, some of the operators in `multiprecision` are removed.
they are the symmetric form of the another variant. if they were
not removed, compiler would, for instance, find ambiguous
overloaded operator '=='.

this change is a cleanup to modernize the code base with C++20
features.

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>

Closes #13687
This commit is contained in:
Kefu Chai
2023-04-26 13:00:47 +08:00
committed by Botond Dénes
parent 3e92bcaa20
commit f5b05cf981
75 changed files with 38 additions and 413 deletions

View File

@@ -35,16 +35,9 @@ public:
///
authenticated_user() = default;
explicit authenticated_user(std::string_view name);
friend bool operator==(const authenticated_user&, const authenticated_user&) noexcept = default;
};
inline bool operator==(const authenticated_user& u1, const authenticated_user& u2) noexcept {
return u1.name == u2.name;
}
inline bool operator!=(const authenticated_user& u1, const authenticated_user& u2) noexcept {
return !(u1 == u2);
}
const authenticated_user& anonymous_user() noexcept;
inline bool is_anonymous(const authenticated_user& u) noexcept {

View File

@@ -39,10 +39,6 @@ inline bool operator==(const permission_details& pd1, const permission_details&
== std::forward_as_tuple(pd2.role_name, pd2.resource, pd2.permissions.mask());
}
inline bool operator!=(const permission_details& pd1, const permission_details& pd2) {
return !(pd1 == pd2);
}
inline bool operator<(const permission_details& pd1, const permission_details& pd2) {
return std::forward_as_tuple(pd1.role_name, pd1.resource, pd1.permissions)
< std::forward_as_tuple(pd2.role_name, pd2.resource, pd2.permissions);

View File

@@ -117,20 +117,12 @@ private:
friend class functions_resource_view;
friend bool operator<(const resource&, const resource&);
friend bool operator==(const resource&, const resource&);
friend bool operator==(const resource&, const resource&) = default;
friend resource parse_resource(std::string_view);
};
bool operator<(const resource&, const resource&);
inline bool operator==(const resource& r1, const resource& r2) {
return (r1._kind == r2._kind) && (r1._parts == r2._parts);
}
inline bool operator!=(const resource& r1, const resource& r2) {
return !(r1 == r2);
}
std::ostream& operator<<(std::ostream&, const resource&);
class resource_kind_mismatch : public std::invalid_argument {

View File

@@ -17,10 +17,6 @@ std::ostream& operator<<(std::ostream& os, const role_or_anonymous& mr) {
return os;
}
bool operator==(const role_or_anonymous& mr1, const role_or_anonymous& mr2) noexcept {
return mr1.name == mr2.name;
}
bool is_anonymous(const role_or_anonymous& mr) noexcept {
return !mr.name.has_value();
}

View File

@@ -26,16 +26,11 @@ public:
role_or_anonymous() = default;
role_or_anonymous(std::string_view name) : name(name) {
}
friend bool operator==(const role_or_anonymous&, const role_or_anonymous&) noexcept = default;
};
std::ostream& operator<<(std::ostream&, const role_or_anonymous&);
bool operator==(const role_or_anonymous&, const role_or_anonymous&) noexcept;
inline bool operator!=(const role_or_anonymous& mr1, const role_or_anonymous& mr2) noexcept {
return !(mr1 == mr2);
}
bool is_anonymous(const role_or_anonymous&) noexcept;
}

View File

@@ -75,12 +75,7 @@ public:
++(*this);
return tmp;
}
bool operator==(const fragment_iterator& other) const {
return _current == other._current;
}
bool operator!=(const fragment_iterator& other) const {
return _current != other._current;
}
bool operator==(const fragment_iterator&) const = default;
};
using const_iterator = fragment_iterator;
@@ -432,10 +427,6 @@ public:
return true;
}
bool operator!=(const bytes_ostream& other) const {
return !(*this == other);
}
// Makes this instance empty.
//
// The first buffer is not deallocated, so callers may rely on the

View File

@@ -68,7 +68,6 @@ public:
_pos = -1;
}
bool operator==(const iterator& o) const { return _pos == o._pos; }
bool operator!=(const iterator& o) const { return _pos != o._pos; }
};
public:
cartesian_product(const std::vector<std::vector<T>>& vec_of_vecs) : _vec_of_vecs(vec_of_vecs) {}

View File

@@ -65,7 +65,6 @@ public:
void ttl(int v) { _ttl = v; }
bool operator==(const options& o) const;
bool operator!=(const options& o) const;
};
} // namespace cdc

View File

@@ -395,9 +395,6 @@ bool cdc::options::operator==(const options& o) const {
return enabled() == o.enabled() && _preimage == o._preimage && _postimage == o._postimage && _ttl == o._ttl
&& _delta_mode == o._delta_mode;
}
bool cdc::options::operator!=(const options& o) const {
return !(*this == o);
}
namespace cdc {
@@ -635,9 +632,6 @@ public:
bool operator==(const collection_iterator& x) const {
return _v == x._v;
}
bool operator!=(const collection_iterator& x) const {
return !(*this == x);
}
private:
void next() {
--_rem;

View File

@@ -93,9 +93,6 @@ public:
bool operator==(const iterator& other) const {
return _position == other._position;
}
bool operator!=(const iterator& other) const {
return !(*this == other);
}
};
public:
explicit partition_cells_range(const mutation_partition& mp) : _mp(mp) { }

View File

@@ -75,8 +75,7 @@ public:
const interval::interval_type& iv = *_i;
return position_range{iv.lower().position(), iv.upper().position()};
}
bool operator==(const position_range_iterator& other) const { return _i == other._i; }
bool operator!=(const position_range_iterator& other) const { return _i != other._i; }
bool operator==(const position_range_iterator& other) const = default;
position_range_iterator& operator++() {
++_i;
return *this;

View File

@@ -31,25 +31,10 @@ public:
const dht::ring_position_view& position() const {
return *_rpv;
}
friend std::strong_ordering tri_compare(const compatible_ring_position_or_view& x, const compatible_ring_position_or_view& y) {
return dht::ring_position_tri_compare(*x._schema, x.position(), y.position());
std::strong_ordering operator<=>(const compatible_ring_position_or_view& other) const {
return dht::ring_position_tri_compare(*_schema, position(), other.position());
}
friend bool operator<(const compatible_ring_position_or_view& x, const compatible_ring_position_or_view& y) {
return tri_compare(x, y) < 0;
}
friend bool operator<=(const compatible_ring_position_or_view& x, const compatible_ring_position_or_view& y) {
return tri_compare(x, y) <= 0;
}
friend bool operator>(const compatible_ring_position_or_view& x, const compatible_ring_position_or_view& y) {
return tri_compare(x, y) > 0;
}
friend bool operator>=(const compatible_ring_position_or_view& x, const compatible_ring_position_or_view& y) {
return tri_compare(x, y) >= 0;
}
friend bool operator==(const compatible_ring_position_or_view& x, const compatible_ring_position_or_view& y) {
return tri_compare(x, y) == 0;
}
friend bool operator!=(const compatible_ring_position_or_view& x, const compatible_ring_position_or_view& y) {
return tri_compare(x, y) != 0;
bool operator==(const compatible_ring_position_or_view& other) const {
return *this <=> other == 0;
}
};

View File

@@ -123,10 +123,6 @@ public:
bool operator==(const iterator& other) const {
return _offset == other._offset && other._i == _i;
}
bool operator!=(const iterator& other) const {
return !(*this == other);
}
};
// A trichotomic comparator defined on @CompoundType representations which
@@ -429,7 +425,6 @@ public:
const value_type& operator*() const { return _current; }
const value_type* operator->() const { return &_current; }
bool operator!=(const iterator& i) const { return _v.begin() != i._v.begin(); }
bool operator==(const iterator& i) const { return _v.begin() == i._v.begin(); }
friend class composite;
@@ -636,7 +631,6 @@ public:
}
bool operator==(const composite_view& k) const { return k._bytes == _bytes && k._is_compound == _is_compound; }
bool operator!=(const composite_view& k) const { return !(k == *this); }
friend fmt::formatter<composite_view>;
};

View File

@@ -175,10 +175,6 @@ bool compression_parameters::operator==(const compression_parameters& other) con
&& _crc_check_chance == other._crc_check_chance;
}
bool compression_parameters::operator!=(const compression_parameters& other) const {
return !(*this == other);
}
void compression_parameters::validate_options(const std::map<sstring, sstring>& options) {
// currently, there are no options specific to a particular compressor
static std::set<sstring> keywords({

View File

@@ -105,7 +105,6 @@ public:
void validate();
std::map<sstring, sstring> get_options() const;
bool operator==(const compression_parameters& other) const;
bool operator!=(const compression_parameters& other) const;
static compression_parameters no_compression() {
return compression_parameters(nullptr);

View File

@@ -78,9 +78,6 @@ public:
return id() == other.id() && value() == other.value()
&& logical_clock() == other.logical_clock();
}
bool operator!=(const basic_counter_shard_view& other) const {
return !(*this == other);
}
struct less_compare_by_id {
bool operator()(const basic_counter_shard_view& x, const basic_counter_shard_view& y) const {

View File

@@ -57,13 +57,7 @@ public:
const cache_key_type& key() const { return _key; }
bool operator==(const authorized_prepared_statements_cache_key& other) const {
return _key == other._key;
}
bool operator!=(const authorized_prepared_statements_cache_key& other) const {
return !(*this == other);
}
bool operator==(const authorized_prepared_statements_cache_key&) const = default;
static size_t hash(const auth::authenticated_user& user, const cql3::prepared_cache_key_type::cache_key_type& prep_cache_key) {
return utils::hash_combine(std::hash<auth::authenticated_user>()(user), utils::tuple_hash()(prep_cache_key));

View File

@@ -96,10 +96,6 @@ bool column_identifier_raw::operator==(const column_identifier_raw& other) const
return _text == other._text;
}
bool column_identifier_raw::operator!=(const column_identifier_raw& other) const {
return !operator==(other);
}
sstring column_identifier_raw::to_string() const {
return _text;
}

View File

@@ -88,8 +88,6 @@ public:
bool operator==(const column_identifier_raw& other) const;
bool operator!=(const column_identifier_raw& other) const;
virtual sstring to_string() const;
sstring to_cql_string() const;

View File

@@ -56,10 +56,6 @@ bool operator==(const expression& e1, const expression& e2) {
}, e1);
}
bool operator!=(const expression& e1, const expression& e2) {
return !(e1 == e2);
}
expression::expression(const expression& o)
: _v(std::make_unique<impl>(*o._v)) {
}

View File

@@ -58,13 +58,7 @@ public:
return key.key().second;
}
bool operator==(const prepared_cache_key_type& other) const {
return _key == other._key;
}
bool operator!=(const prepared_cache_key_type& other) const {
return !(*this == other);
}
bool operator==(const prepared_cache_key_type& other) const = default;
};
class prepared_statements_cache {

View File

@@ -56,13 +56,7 @@ public:
return size_t(_type);
}
bool operator==(const statement_type& other) const {
return _type == other._type;
}
bool operator!=(const statement_type& other) const {
return !(_type == other._type);
}
bool operator==(const statement_type&) const = default;
friend std::ostream &operator<<(std::ostream &os, const statement_type& t) {
switch (t._type) {

View File

@@ -103,9 +103,6 @@ public:
return _cf_names_idx == i._cf_names_idx
&& _ranges_idx == i._ranges_idx;
}
bool operator!=(const virtual_row_iterator& i) const {
return !(*this == i);
}
};
/**

View File

@@ -160,9 +160,6 @@ public:
bool operator==(const i_partitioner& o) const {
return name() == o.name();
}
bool operator!=(const i_partitioner& o) const {
return !(*this == o);
}
};
//

View File

@@ -63,11 +63,6 @@ public:
bool operator==(const sharder& o) const {
return _shard_count == o._shard_count && _sharding_ignore_msb_bits == o._sharding_ignore_msb_bits;
}
bool operator!=(const sharder& o) const {
return !(*this == o);
}
};
inline std::ostream& operator<<(std::ostream& os, const sharder& sharder) {

View File

@@ -451,11 +451,3 @@ seastar::sstring to_string(const cql_duration& d) {
ss << d;
return ss.str();
}
bool operator==(const cql_duration& d1, const cql_duration& d2) noexcept {
return (d1.months == d2.months) && (d1.days == d2.days) && (d1.nanoseconds == d2.nanoseconds);
}
bool operator!=(const cql_duration& d1, const cql_duration& d2) noexcept {
return !(d1 == d2);
}

View File

@@ -110,6 +110,12 @@ public:
months_counter::value_type months{0};
days_counter::value_type days{0};
nanoseconds_counter::value_type nanoseconds{0};
//
// Note that equality comparison is based on exact counter matches. It is not valid to expect equivalency across
// counters like months and days. See the documentation for `duration` for more.
//
friend bool operator==(const cql_duration&, const cql_duration&) noexcept = default;
};
//
@@ -121,11 +127,3 @@ std::ostream& operator<<(std::ostream& os, const cql_duration& d);
// See above.
seastar::sstring to_string(const cql_duration&);
//
// Note that equality comparison is based on exact counter matches. It is not valid to expect equivalency across
// counters like months and days. See the documentation for `duration` for more.
//
bool operator==(const cql_duration&, const cql_duration&) noexcept;
bool operator!=(const cql_duration&, const cql_duration&) noexcept;

View File

@@ -62,9 +62,7 @@ public:
return addr().as_ipv4_address().ip;
}
sstring to_sstring() const;
friend inline bool operator==(const inet_address& x, const inet_address& y) noexcept {
return x._addr == y._addr;
}
friend inline bool operator==(const inet_address& x, const inet_address& y) noexcept = default;
friend inline bool operator<(const inet_address& x, const inet_address& y) noexcept {
return x.bytes() < y.bytes();
}

View File

@@ -147,7 +147,6 @@ public:
factory_key(const factory_key&) = default;
bool operator==(const factory_key& o) const = default;
bool operator!=(const factory_key& o) const = default;
sstring to_sstring() const;
};

View File

@@ -87,10 +87,6 @@ bool mutation::operator==(const mutation& m) const {
&& partition().equal(*schema(), m.partition(), *m.schema());
}
bool mutation::operator!=(const mutation& m) const {
return !(*this == m);
}
uint64_t
mutation::live_row_count(gc_clock::time_point query_time) const {
return partition().live_row_count(*schema(), query_time);

View File

@@ -135,7 +135,6 @@ public:
const table_id& column_family_id() const { return _ptr->_schema->id(); }
// Consistent with hash<canonical_mutation>
bool operator==(const mutation&) const;
bool operator!=(const mutation&) const;
public:
// Consumes the mutation's content.
//

View File

@@ -610,9 +610,6 @@ public:
}
return _ttl == no_ttl || _expiry == other._expiry;
}
bool operator!=(const row_marker& other) const {
return !(*this == other);
}
// Consistent with operator==()
template<typename Hasher>
void feed_hash(Hasher& h) const {
@@ -652,7 +649,6 @@ public:
}
bool operator==(const shadowable_tombstone&) const = default;
bool operator!=(const shadowable_tombstone&) const = default;
explicit operator bool() const {
return bool(_tomb);
@@ -747,9 +743,6 @@ public:
bool operator==(const row_tombstone& t) const {
return _shadowable == t._shadowable;
}
bool operator!=(const row_tombstone& t) const {
return _shadowable != t._shadowable;
}
explicit operator bool() const {
return bool(_shadowable);

View File

@@ -251,9 +251,6 @@ public:
bool operator==(const change_mark& m) const {
return _reclaim_count == m._reclaim_count && _versions_count == m._versions_count;
}
bool operator!=(const change_mark& m) const {
return !(*this == m);
}
explicit operator bool() const {
return _reclaim_count > 0;
}

View File

@@ -34,7 +34,6 @@ struct tombstone final {
std::strong_ordering operator<=>(const tombstone& t) const = default;
bool operator==(const tombstone&) const = default;
bool operator!=(const tombstone&) const = default;
explicit operator bool() const {
return timestamp != api::missing_timestamp;

View File

@@ -46,10 +46,6 @@ reconcilable_result::operator==(const reconcilable_result& other) const {
return boost::equal(_partitions, other._partitions);
}
bool reconcilable_result::operator!=(const reconcilable_result& other) const {
return !(*this == other);
}
std::ostream& operator<<(std::ostream& out, const reconcilable_result::printer& pr) {
out << "{rows=" << pr.self.row_count() << ", short_read="
<< pr.self.is_short_read() << ", [";

View File

@@ -61,10 +61,6 @@ struct partition {
bool operator==(const partition& other) const {
return row_count() == other.row_count() && _m.representation() == other._m.representation();
}
bool operator!=(const partition& other) const {
return !(*this == other);
}
};
// The partitions held by this object are ordered according to dht::decorated_key ordering and non-overlapping.
@@ -111,7 +107,6 @@ public:
}
bool operator==(const reconcilable_result& other) const;
bool operator!=(const reconcilable_result& other) const;
struct printer {
const reconcilable_result& self;

View File

@@ -88,19 +88,10 @@ public:
throw no_value(column_name);
}
const std::unordered_map<sstring, non_null_data_value>& cells() const { return _cells; }
friend inline bool operator==(const result_set_row& x, const result_set_row& y);
friend inline bool operator!=(const result_set_row& x, const result_set_row& y);
friend inline bool operator==(const result_set_row& x, const result_set_row& y) = default;
friend std::ostream& operator<<(std::ostream& out, const result_set_row& row);
};
inline bool operator==(const result_set_row& x, const result_set_row& y) {
return x._schema == y._schema && x._cells == y._cells;
}
inline bool operator!=(const result_set_row& x, const result_set_row& y) {
return !(x == y);
}
// Result set is an in-memory representation of query results in
// deserialized format. To obtain a result set, use the result_set_builder
// class as a visitor to query_result::consume() function.

View File

@@ -268,12 +268,7 @@ public:
result_digest() = default;
result_digest(type&& digest) : _digest(std::move(digest)) {}
const type& get() const { return _digest; }
bool operator==(const result_digest& rh) const {
return _digest == rh._digest;
}
bool operator!=(const result_digest& rh) const {
return _digest != rh._digest;
}
bool operator==(const result_digest& rh) const = default;
};
//

View File

@@ -20,15 +20,7 @@ public:
void add(const repair_hash& other) {
hash ^= other.hash;
}
bool operator==(const repair_hash& x) const {
return x.hash == hash;
}
bool operator!=(const repair_hash& x) const {
return x.hash != hash;
}
bool operator<(const repair_hash& x) const {
return x.hash < hash;
}
std::strong_ordering operator<=>(const repair_hash&) const = default;
friend std::ostream& operator<<(std::ostream& os, const repair_hash& x) {
return os << x.hash;
}

View File

@@ -77,14 +77,3 @@ caching_options
caching_options::from_sstring(const sstring& str) {
return from_map(rjson::parse_to_map<std::map<sstring, sstring>>(str));
}
bool
caching_options::operator==(const caching_options& other) const {
return _key_cache == other._key_cache && _row_cache == other._row_cache
&& _enabled == other._enabled;
}
bool
caching_options::operator!=(const caching_options& other) const {
return !(*this == other);
}

View File

@@ -42,9 +42,5 @@ public:
static caching_options from_map(const std::map<sstring, sstring>& map);
static caching_options from_sstring(const sstring& str);
bool operator==(const caching_options& other) const;
bool operator!=(const caching_options& other) const;
bool operator==(const caching_options& other) const = default;
};

View File

@@ -73,10 +73,6 @@ bool operator==(const column_mapping_entry& lhs, const column_mapping_entry& rhs
return lhs.name() == rhs.name() && lhs.type() == rhs.type();
}
bool operator!=(const column_mapping_entry& lhs, const column_mapping_entry& rhs) {
return !(lhs == rhs);
}
bool operator==(const column_mapping& lhs, const column_mapping& rhs) {
const auto& lhs_columns = lhs.columns(), rhs_columns = rhs.columns();
if (lhs_columns.size() != rhs_columns.size()) {

View File

@@ -214,12 +214,7 @@ public:
double get_value() const {
return _v;
}
bool operator==(const speculative_retry& other) const {
return _t == other._t && _v == other._v;
}
bool operator!=(const speculative_retry& other) const {
return !(*this == other);
}
bool operator==(const speculative_retry& other) const = default;
};
typedef std::unordered_map<sstring, sstring> index_options_map;
@@ -394,7 +389,6 @@ public:
};
bool operator==(const column_definition&, const column_definition&);
inline bool operator!=(const column_definition& a, const column_definition& b) { return !(a == b); }
static constexpr int DEFAULT_MIN_COMPACTION_THRESHOLD = 4;
static constexpr int DEFAULT_MAX_COMPACTION_THRESHOLD = 32;
@@ -422,7 +416,6 @@ public:
};
bool operator==(const column_mapping_entry& lhs, const column_mapping_entry& rhs);
bool operator!=(const column_mapping_entry& lhs, const column_mapping_entry& rhs);
// Encapsulates information needed for converting mutations between different schema versions.
//

View File

@@ -125,10 +125,6 @@ bool schema_mutations::operator==(const schema_mutations& other) const {
;
}
bool schema_mutations::operator!=(const schema_mutations& other) const {
return !(*this == other);
}
bool schema_mutations::live() const {
return _columnfamilies.live_row_count() > 0 || _columns.live_row_count() > 0 ||
(_view_virtual_columns && _view_virtual_columns->live_row_count() > 0) ||

View File

@@ -128,7 +128,6 @@ public:
std::optional<sstring> partitioner() const;
bool operator==(const schema_mutations&) const;
bool operator!=(const schema_mutations&) const;
schema_mutations& operator+=(schema_mutations&&);
// Returns true iff any mutations contain any live cells

View File

@@ -87,9 +87,6 @@ public:
bool operator==(const iterator& other) const {
return _left == other._left;
}
bool operator!=(const iterator& other) const {
return !(*this == other);
}
};
using const_iterator = iterator;

View File

@@ -25,11 +25,9 @@ namespace qos {
struct service_level_options {
struct unset_marker {
bool operator==(const unset_marker&) const { return true; };
bool operator!=(const unset_marker&) const { return false; };
};
struct delete_marker {
bool operator==(const delete_marker&) const { return true; };
bool operator!=(const delete_marker&) const { return false; };
};
enum class workload_type {
@@ -46,7 +44,6 @@ struct service_level_options {
service_level_options merge_with(const service_level_options& other) const;
bool operator==(const service_level_options& other) const = default;
bool operator!=(const service_level_options& other) const = default;
static std::string_view to_string(const workload_type& wt);
static std::optional<workload_type> parse_workload_type(std::string_view sv);

View File

@@ -232,10 +232,6 @@ struct compression {
return _index == other._index;
}
bool operator!=(const const_iterator& other) const {
return !(*this == other);
}
bool operator<(const const_iterator& other) const {
return _index < other._index;
}

View File

@@ -40,10 +40,6 @@ inline bool operator==(const processing_result& result, proceed value) {
return (p != nullptr && *p == value);
}
inline bool operator!=(const processing_result& result, proceed value) {
return !(result == value);
}
enum class read_status { ready, waiting };
// Incremental parser for primitive data types.

View File

@@ -63,7 +63,6 @@ public:
bool operator<(const promoted_index_block& other) const { return index < other.index; }
bool operator==(const promoted_index_block& other) const { return index == other.index; }
bool operator!=(const promoted_index_block& other) const { return index != other.index; }
friend std::ostream& operator<<(std::ostream& out, const promoted_index_block& b) {
return out << "{idx=" << b.index

View File

@@ -71,13 +71,7 @@ struct deletion_time {
(marked_for_delete_at == std::numeric_limits<int64_t>::min());
}
bool operator==(const deletion_time& d) {
return local_deletion_time == d.local_deletion_time &&
marked_for_delete_at == d.marked_for_delete_at;
}
bool operator!=(const deletion_time& d) {
return !(*this == d);
}
bool operator==(const deletion_time& d) const = default;
explicit operator tombstone() {
return !live() ? tombstone(marked_for_delete_at, gc_clock::time_point(gc_clock::duration(local_deletion_time))) : tombstone();
}

View File

@@ -54,12 +54,7 @@ struct stream_bytes {
ret += y;
return ret;
}
friend bool operator!=(const stream_bytes& x, const stream_bytes& y) {
return x.bytes_sent != y.bytes_sent && x.bytes_received != y.bytes_received;
}
friend bool operator==(const stream_bytes& x, const stream_bytes& y) {
return x.bytes_sent == y.bytes_sent && x.bytes_received == y.bytes_received;
}
friend bool operator==(const stream_bytes&, const stream_bytes&) = default;
stream_bytes& operator+=(const stream_bytes& x) {
bytes_sent += x.bytes_sent;
bytes_received += x.bytes_received;

View File

@@ -38,11 +38,7 @@ public:
return seastar::format("{}.{}", key, sub_key);
}
bool operator==(const compound_key& other) const {
return key == other.key && sub_key == other.sub_key;
}
bool operator!=(const compound_key& other) const { return !(*this == other); }
bool operator==(const compound_key&) const = default;
struct compare {
std::strong_ordering operator()(const int& a, const int& b) const { return a <=> b; }

View File

@@ -26,13 +26,11 @@ struct add_op {
sstring name;
service_level_options slo;
bool operator==(const add_op& other) const = default;
bool operator!=(const add_op& other) const = default;
};
struct remove_op {
sstring name;
bool operator==(const remove_op& other) const = default;
bool operator!=(const remove_op& other) const = default;
};
struct change_op {
@@ -40,7 +38,6 @@ struct change_op {
service_level_options slo_before;
service_level_options slo_after;
bool operator==(const change_op& other) const = default;
bool operator!=(const change_op& other) const = default;
};
using service_level_op = std::variant<add_op, remove_op, change_op>;

View File

@@ -49,12 +49,7 @@ public:
return it;
}
bool operator==(const input_iterator_wrapper& other) const {
return _it == other._it;
}
bool operator!=(const input_iterator_wrapper& other) const {
return _it != other._it;
}
bool operator==(const input_iterator_wrapper& other) const = default;
};
template<typename T>

View File

@@ -56,16 +56,6 @@ seastar::sstring tombstone_gc_options::to_sstring() const {
return rjson::print(rjson::from_string_map(to_map()));
}
bool
tombstone_gc_options::operator==(const tombstone_gc_options& other) const {
return _mode == other._mode && _propagation_delay_in_seconds == other._propagation_delay_in_seconds;
}
bool
tombstone_gc_options::operator!=(const tombstone_gc_options& other) const {
return !(*this == other);
}
std::ostream& operator<<(std::ostream& os, const tombstone_gc_mode& mode) {
switch (mode) {
case tombstone_gc_mode::timeout: return os << "timeout";

View File

@@ -27,8 +27,7 @@ public:
}
std::map<seastar::sstring, seastar::sstring> to_map() const;
seastar::sstring to_sstring() const;
bool operator==(const tombstone_gc_options& other) const;
bool operator!=(const tombstone_gc_options& other) const;
bool operator==(const tombstone_gc_options&) const = default;
};
std::ostream& operator<<(std::ostream& os, const tombstone_gc_mode& m);

View File

@@ -97,9 +97,6 @@ public:
bool operator==(const listlike_partial_deserializing_iterator& x) const {
return _remain == x._remain;
}
bool operator!=(const listlike_partial_deserializing_iterator& x) const {
return _remain != x._remain;
}
static listlike_partial_deserializing_iterator begin(managed_bytes_view& in) {
return { in };
}

View File

@@ -60,9 +60,6 @@ public:
bool operator==(const tuple_deserializing_iterator& x) const {
return _v == x._v;
}
bool operator!=(const tuple_deserializing_iterator& x) const {
return !operator==(x);
}
private:
void parse() {
_current = std::nullopt;

View File

@@ -256,7 +256,6 @@ public:
bytes_opt serialize() const;
bytes serialize_nonnull() const;
friend bool operator==(const data_value& x, const data_value& y);
friend inline bool operator!=(const data_value& x, const data_value& y);
friend class abstract_type;
static data_value make_null(data_type type) {
return data_value(nullptr, std::move(type));
@@ -549,11 +548,6 @@ public:
bool operator==(const data_value& x, const data_value& y);
inline bool operator!=(const data_value& x, const data_value& y)
{
return !(x == y);
}
using bytes_view_opt = std::optional<bytes_view>;
using managed_bytes_view_opt = std::optional<managed_bytes_view>;

View File

@@ -46,12 +46,7 @@ public:
operator--();
return it;
}
bool operator==(const iterator& other) const {
return _position == other._position;
}
bool operator!=(const iterator& other) const {
return !(*this == other);
}
bool operator==(const iterator&) const = default;
};
template <typename ValueType>
@@ -76,12 +71,7 @@ public:
operator++();
return it;
}
bool operator==(const reverse_iterator& other) const {
return _position == other._position;
}
bool operator!=(const reverse_iterator& other) const {
return !(*this == other);
}
bool operator==(const reverse_iterator& other) const = default;
};
class range {

View File

@@ -638,7 +638,6 @@ public:
}
bool operator==(const iterator_base& o) const noexcept { return is_end() ? o.is_end() : _data == o._data; }
bool operator!=(const iterator_base& o) const noexcept { return !(*this == o); }
};
using iterator_base_const = iterator_base<true>;

View File

@@ -264,9 +264,6 @@ public:
bool operator==(iterator_type x) const {
return _i == x._i;
}
bool operator!=(iterator_type x) const {
return _i != x._i;
}
bool operator<(iterator_type x) const {
return _i < x._i;
}
@@ -302,9 +299,6 @@ public:
bool operator==(const chunked_vector& x) const {
return boost::equal(*this, x);
}
bool operator!=(const chunked_vector& x) const {
return !operator==(x);
}
};

View File

@@ -1991,7 +1991,6 @@ public:
reference operator*() const noexcept { return *_value; }
bool operator==(const iterator_base& o) const noexcept { return _value == o._value; }
bool operator!=(const iterator_base& o) const noexcept { return !(*this == o); }
};
using iterator = iterator_base<false>;

View File

@@ -89,8 +89,7 @@ public:
return cur;
}
bool operator==(const iterator_base& o) const noexcept { return _bucket == o._bucket && _idx == o._idx; }
bool operator!=(const iterator_base& o) const noexcept { return !(*this == o); }
bool operator==(const iterator_base& o) const noexcept = default;
};
using const_iterator = iterator_base<true>;

View File

@@ -177,9 +177,6 @@ public:
bool operator==(const iterator& other) const noexcept {
return _left == other._left;
}
bool operator!=(const iterator& other) const noexcept {
return !(*this == other);
}
};
using const_iterator = iterator;
@@ -278,10 +275,6 @@ public:
}
return this_it == end() && other_it == other.end();
}
bool operator!=(const fragmented_temporary_buffer::view& other) const noexcept {
return !(*this == other);
}
};
static_assert(FragmentRange<fragmented_temporary_buffer::view>);
static_assert(FragmentedView<fragmented_temporary_buffer::view>);

View File

@@ -799,7 +799,6 @@ public:
}
bool operator==(const iterator_base& o) const noexcept { return is_end() ? o.is_end() : _hook == o._hook; }
bool operator!=(const iterator_base& o) const noexcept { return !(*this == o); }
operator bool() const noexcept { return !is_end(); }
/*

View File

@@ -716,8 +716,7 @@ public:
}
}
value_ptr(std::nullptr_t) noexcept : _ts_val_ptr() {}
bool operator==(const value_ptr& x) const { return _ts_val_ptr == x._ts_val_ptr; }
bool operator!=(const value_ptr& x) const { return !operator==(x); }
bool operator==(const value_ptr&) const = default;
explicit operator bool() const noexcept { return bool(_ts_val_ptr); }
value_type& operator*() const noexcept { return _ts_val_ptr->value(); }
value_type* operator->() const noexcept { return &_ts_val_ptr->value(); }

View File

@@ -144,8 +144,7 @@ public:
return *this;
}
explicit operator bool() const noexcept { return bool(_e); }
bool operator==(const entry_ptr& x) const { return _e == x._e; }
bool operator!=(const entry_ptr& x) const { return !operator==(x); }
bool operator==(const entry_ptr&) const = default;
element_type& operator*() const noexcept { return _e->value(); }
element_type* operator->() const noexcept { return &_e->value(); }

View File

@@ -178,9 +178,6 @@ public:
bool operator==(const hist_iterator& other) const noexcept {
return _b == other._b && _it == other._it;
}
bool operator!=(const hist_iterator& other) const noexcept {
return !(*this == other);
}
};
using iterator = hist_iterator<false>;
using const_iterator = hist_iterator<true>;

View File

@@ -240,9 +240,6 @@ public:
bool operator==(iterator_type x) const {
return _i == x._i;
}
bool operator!=(iterator_type x) const {
return _i != x._i;
}
bool operator<(iterator_type x) const {
return _i < x._i;
}
@@ -278,9 +275,6 @@ public:
bool operator==(const chunked_managed_vector& x) const {
return boost::equal(*this, x);
}
bool operator!=(const chunked_managed_vector& x) const {
return !operator==(x);
}
// Returns the amount of external memory used to hold inserted items.
// Takes into account reserved space.

View File

@@ -102,8 +102,7 @@ public:
explicit operator bool() const { return _ptr && _ptr->engaged(); }
bool operator==(const weak_ptr& o) const noexcept { return _ptr == o._ptr; }
bool operator!=(const weak_ptr& o) const noexcept { return _ptr != o._ptr; }
bool operator==(const weak_ptr& o) const noexcept = default;
// Returns true iff there are no other weak_ptr:s to this object.
bool unique() const {

View File

@@ -294,10 +294,6 @@ public:
}
}
bool operator!=(const managed_bytes& o) const {
return !(*this == o);
}
bytes_view::value_type& operator[](size_type index) {
return value_at_index(index);
}

View File

@@ -10,6 +10,7 @@
#include <boost/multiprecision/cpp_int.hpp>
#include <iosfwd>
#include <compare>
namespace utils {
@@ -161,33 +162,12 @@ public:
multiprecision_int operator>>(const T& x) const {
return cpp_int(_v >> maybe_unwrap(x));
}
bool operator==(const multiprecision_int& x) const {
return _v == x._v;
}
bool operator!=(const multiprecision_int& x) const {
return _v != x._v;
}
bool operator>(const multiprecision_int& x) const {
return _v > x._v;
}
bool operator>=(const multiprecision_int& x) const {
return _v >= x._v;
}
bool operator<(const multiprecision_int& x) const {
return _v < x._v;
}
bool operator<=(const multiprecision_int& x) const {
return _v <= x._v;
}
std::strong_ordering operator<=>(const multiprecision_int& x) const = default;
template <typename T>
bool operator==(const T& x) const {
return _v == maybe_unwrap(x);
}
template <typename T>
bool operator!=(const T& x) const {
return _v != maybe_unwrap(x);
}
template <typename T>
bool operator>(const T& x) const {
return _v > maybe_unwrap(x);
}
@@ -231,30 +211,6 @@ public:
friend multiprecision_int operator>>(const T& x, const multiprecision_int& y) {
return cpp_int(maybe_unwrap(x) >> y._v);
}
template <typename T>
friend bool operator==(const T& x, const multiprecision_int& y) {
return maybe_unwrap(x) == y._v;
}
template <typename T>
friend bool operator!=(const T& x, const multiprecision_int& y) {
return maybe_unwrap(x) != y._v;
}
template <typename T>
friend bool operator>(const T& x, const multiprecision_int& y) {
return maybe_unwrap(x) > y._v;
}
template <typename T>
friend bool operator>=(const T& x, const multiprecision_int& y) {
return maybe_unwrap(x) >= y._v;
}
template <typename T>
friend bool operator<(const T& x, const multiprecision_int& y) {
return maybe_unwrap(x) < y._v;
}
template <typename T>
friend bool operator<=(const T& x, const multiprecision_int& y) {
return maybe_unwrap(x) <= y._v;
}
std::string str() const;
friend std::ostream& operator<<(std::ostream& os, const multiprecision_int& x);
};

View File

@@ -28,26 +28,7 @@ public:
return v;
}
bool operator==(version v) const {
return _version == v._version;
}
bool operator!=(version v) const {
return _version != v._version;
}
bool operator<(version v) const {
return _version < v._version;
}
bool operator<=(version v) {
return _version <= v._version;
}
bool operator>(version v) {
return _version > v._version;
}
bool operator>=(version v) {
return _version >= v._version;
}
std::strong_ordering operator<=>(const version&) const = default;
};
inline const seastar::sstring& release() {