From f5b05cf98161c721ded7ae3ee6f07ed01d32af14 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Wed, 26 Apr 2023 13:00:47 +0800 Subject: [PATCH] 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 Closes #13687 --- auth/authenticated_user.hh | 9 +--- auth/authorizer.hh | 4 -- auth/resource.hh | 10 +--- auth/role_or_anonymous.cc | 4 -- auth/role_or_anonymous.hh | 7 +-- bytes_ostream.hh | 11 +---- cartesian_product.hh | 1 - cdc/cdc_options.hh | 1 - cdc/log.cc | 6 --- cell_locking.hh | 3 -- clustering_interval_set.hh | 3 +- compatible_ring_position.hh | 23 ++------- compound_compat.hh | 6 --- compress.cc | 4 -- compress.hh | 1 - counters.hh | 3 -- cql3/authorized_prepared_statements_cache.hh | 8 +--- cql3/column_identifier.cc | 4 -- cql3/column_identifier.hh | 2 - cql3/expr/expression.cc | 4 -- cql3/prepared_statements_cache.hh | 8 +--- cql3/statements/statement_type.hh | 8 +--- db/size_estimates_virtual_reader.cc | 3 -- dht/i_partitioner.hh | 3 -- dht/token-sharding.hh | 5 -- duration.cc | 8 ---- duration.hh | 14 +++--- gms/inet_address.hh | 4 +- locator/abstract_replication_strategy.hh | 1 - mutation/mutation.cc | 4 -- mutation/mutation.hh | 1 - mutation/mutation_partition.hh | 7 --- mutation/partition_version.hh | 3 -- mutation/tombstone.hh | 1 - mutation_query.cc | 4 -- mutation_query.hh | 5 -- query-result-set.hh | 11 +---- query-result.hh | 7 +-- repair/hash.hh | 10 +--- schema/caching_options.cc | 11 ----- schema/caching_options.hh | 6 +-- schema/schema.cc | 4 -- schema/schema.hh | 9 +--- schema_mutations.cc | 4 -- schema_mutations.hh | 1 - serializer.hh | 3 -- service/qos/qos_common.hh | 3 -- sstables/compress.hh | 4 -- sstables/consumer.hh | 4 -- sstables/mx/bsearch_clustered_cursor.hh | 1 - sstables/types.hh | 8 +--- streaming/stream_manager.hh | 7 +-- test/boost/double_decker_test.cc | 6 +-- test/boost/service_level_controller_test.cc | 3 -- test/boost/small_vector_test.cc | 7 +-- tombstone_gc_options.cc | 10 ---- tombstone_gc_options.hh | 3 +- ...listlike_partial_deserializing_iterator.hh | 3 -- types/tuple.hh | 3 -- types/types.hh | 6 --- utils/anchorless_list.hh | 14 +----- utils/bptree.hh | 1 - utils/chunked_vector.hh | 6 --- utils/compact-radix-tree.hh | 1 - utils/double-decker.hh | 3 +- utils/fragmented_temporary_buffer.hh | 7 --- utils/intrusive_btree.hh | 1 - utils/loading_cache.hh | 3 +- utils/loading_shared_values.hh | 3 +- utils/log_heap.hh | 3 -- utils/lsa/chunked_managed_vector.hh | 6 --- utils/lsa/weak_ptr.hh | 3 +- utils/managed_bytes.hh | 4 -- utils/multiprecision_int.hh | 48 +------------------ version.hh | 21 +------- 75 files changed, 38 insertions(+), 413 deletions(-) diff --git a/auth/authenticated_user.hh b/auth/authenticated_user.hh index bc7f60bba9..ec4bd0315b 100644 --- a/auth/authenticated_user.hh +++ b/auth/authenticated_user.hh @@ -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 { diff --git a/auth/authorizer.hh b/auth/authorizer.hh index e2d0774ff7..1488418084 100644 --- a/auth/authorizer.hh +++ b/auth/authorizer.hh @@ -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); diff --git a/auth/resource.hh b/auth/resource.hh index 87ff65aef9..cc585975fd 100644 --- a/auth/resource.hh +++ b/auth/resource.hh @@ -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 { diff --git a/auth/role_or_anonymous.cc b/auth/role_or_anonymous.cc index 40dd8ac162..8272c39303 100644 --- a/auth/role_or_anonymous.cc +++ b/auth/role_or_anonymous.cc @@ -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(); } diff --git a/auth/role_or_anonymous.hh b/auth/role_or_anonymous.hh index db3a9e4f9d..01add54151 100644 --- a/auth/role_or_anonymous.hh +++ b/auth/role_or_anonymous.hh @@ -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; } diff --git a/bytes_ostream.hh b/bytes_ostream.hh index 01253c2371..a11d10684e 100644 --- a/bytes_ostream.hh +++ b/bytes_ostream.hh @@ -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 diff --git a/cartesian_product.hh b/cartesian_product.hh index 465723d740..ac8ee78b53 100644 --- a/cartesian_product.hh +++ b/cartesian_product.hh @@ -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>& vec_of_vecs) : _vec_of_vecs(vec_of_vecs) {} diff --git a/cdc/cdc_options.hh b/cdc/cdc_options.hh index 69bd45064c..ef72cf7e0e 100644 --- a/cdc/cdc_options.hh +++ b/cdc/cdc_options.hh @@ -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 diff --git a/cdc/log.cc b/cdc/log.cc index e0bdcad3b7..b1ddcd18ae 100644 --- a/cdc/log.cc +++ b/cdc/log.cc @@ -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; diff --git a/cell_locking.hh b/cell_locking.hh index d3be6c89fd..25590d6c37 100644 --- a/cell_locking.hh +++ b/cell_locking.hh @@ -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) { } diff --git a/clustering_interval_set.hh b/clustering_interval_set.hh index fd7e6263b4..0e4ad31f1c 100644 --- a/clustering_interval_set.hh +++ b/clustering_interval_set.hh @@ -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; diff --git a/compatible_ring_position.hh b/compatible_ring_position.hh index 59c0ee93e6..f75ec437f1 100644 --- a/compatible_ring_position.hh +++ b/compatible_ring_position.hh @@ -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; } }; diff --git a/compound_compat.hh b/compound_compat.hh index 439abde1fa..f51ebbeb71 100644 --- a/compound_compat.hh +++ b/compound_compat.hh @@ -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; }; diff --git a/compress.cc b/compress.cc index c4bac931d0..b8450b8f72 100644 --- a/compress.cc +++ b/compress.cc @@ -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& options) { // currently, there are no options specific to a particular compressor static std::set keywords({ diff --git a/compress.hh b/compress.hh index 5e1de8a5c1..141e2e96c2 100644 --- a/compress.hh +++ b/compress.hh @@ -105,7 +105,6 @@ public: void validate(); std::map 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); diff --git a/counters.hh b/counters.hh index 8d37d41d4f..19760901c2 100644 --- a/counters.hh +++ b/counters.hh @@ -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 { diff --git a/cql3/authorized_prepared_statements_cache.hh b/cql3/authorized_prepared_statements_cache.hh index 1046c4ba3c..5b18ec6c3d 100644 --- a/cql3/authorized_prepared_statements_cache.hh +++ b/cql3/authorized_prepared_statements_cache.hh @@ -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()(user), utils::tuple_hash()(prep_cache_key)); diff --git a/cql3/column_identifier.cc b/cql3/column_identifier.cc index a73d872be0..3b92a8f114 100644 --- a/cql3/column_identifier.cc +++ b/cql3/column_identifier.cc @@ -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; } diff --git a/cql3/column_identifier.hh b/cql3/column_identifier.hh index 4dd5718ed3..2c614f91f7 100644 --- a/cql3/column_identifier.hh +++ b/cql3/column_identifier.hh @@ -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; diff --git a/cql3/expr/expression.cc b/cql3/expr/expression.cc index ee13cde4a7..574acfa4d6 100644 --- a/cql3/expr/expression.cc +++ b/cql3/expr/expression.cc @@ -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(*o._v)) { } diff --git a/cql3/prepared_statements_cache.hh b/cql3/prepared_statements_cache.hh index 0dd40676d5..d92ccbd15e 100644 --- a/cql3/prepared_statements_cache.hh +++ b/cql3/prepared_statements_cache.hh @@ -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 { diff --git a/cql3/statements/statement_type.hh b/cql3/statements/statement_type.hh index d096ce4714..c813362869 100644 --- a/cql3/statements/statement_type.hh +++ b/cql3/statements/statement_type.hh @@ -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) { diff --git a/db/size_estimates_virtual_reader.cc b/db/size_estimates_virtual_reader.cc index 5ea2868f26..bb23589407 100644 --- a/db/size_estimates_virtual_reader.cc +++ b/db/size_estimates_virtual_reader.cc @@ -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); - } }; /** diff --git a/dht/i_partitioner.hh b/dht/i_partitioner.hh index 3dcc2b70b4..285ac7066f 100644 --- a/dht/i_partitioner.hh +++ b/dht/i_partitioner.hh @@ -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); - } }; // diff --git a/dht/token-sharding.hh b/dht/token-sharding.hh index a86d87a310..c715ecd91e 100644 --- a/dht/token-sharding.hh +++ b/dht/token-sharding.hh @@ -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) { diff --git a/duration.cc b/duration.cc index ae8954ab03..b154a65ef5 100644 --- a/duration.cc +++ b/duration.cc @@ -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); -} diff --git a/duration.hh b/duration.hh index 2b60f493bc..493e41cce4 100644 --- a/duration.hh +++ b/duration.hh @@ -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; diff --git a/gms/inet_address.hh b/gms/inet_address.hh index b65ccea6a7..9dba863937 100644 --- a/gms/inet_address.hh +++ b/gms/inet_address.hh @@ -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(); } diff --git a/locator/abstract_replication_strategy.hh b/locator/abstract_replication_strategy.hh index c0bc48c868..589059757c 100644 --- a/locator/abstract_replication_strategy.hh +++ b/locator/abstract_replication_strategy.hh @@ -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; }; diff --git a/mutation/mutation.cc b/mutation/mutation.cc index 6fcefde4b8..242eee1960 100644 --- a/mutation/mutation.cc +++ b/mutation/mutation.cc @@ -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); diff --git a/mutation/mutation.hh b/mutation/mutation.hh index 109ea5cd5b..309cb256d2 100644 --- a/mutation/mutation.hh +++ b/mutation/mutation.hh @@ -135,7 +135,6 @@ public: const table_id& column_family_id() const { return _ptr->_schema->id(); } // Consistent with hash bool operator==(const mutation&) const; - bool operator!=(const mutation&) const; public: // Consumes the mutation's content. // diff --git a/mutation/mutation_partition.hh b/mutation/mutation_partition.hh index 7449b48ee7..7fcfdd391c 100644 --- a/mutation/mutation_partition.hh +++ b/mutation/mutation_partition.hh @@ -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 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); diff --git a/mutation/partition_version.hh b/mutation/partition_version.hh index c7dcaead93..855462a4b1 100644 --- a/mutation/partition_version.hh +++ b/mutation/partition_version.hh @@ -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; } diff --git a/mutation/tombstone.hh b/mutation/tombstone.hh index 18253ed007..061069080c 100644 --- a/mutation/tombstone.hh +++ b/mutation/tombstone.hh @@ -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; diff --git a/mutation_query.cc b/mutation_query.cc index 46d4322e37..18df460e0d 100644 --- a/mutation_query.cc +++ b/mutation_query.cc @@ -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() << ", ["; diff --git a/mutation_query.hh b/mutation_query.hh index ed74e2ff4c..619bf46aca 100644 --- a/mutation_query.hh +++ b/mutation_query.hh @@ -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; diff --git a/query-result-set.hh b/query-result-set.hh index f61cd6e428..e7847c7126 100644 --- a/query-result-set.hh +++ b/query-result-set.hh @@ -88,19 +88,10 @@ public: throw no_value(column_name); } const std::unordered_map& 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. diff --git a/query-result.hh b/query-result.hh index bc04e8de40..2f2e65ab29 100644 --- a/query-result.hh +++ b/query-result.hh @@ -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; }; // diff --git a/repair/hash.hh b/repair/hash.hh index 2de67597b7..06a345402e 100644 --- a/repair/hash.hh +++ b/repair/hash.hh @@ -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; } diff --git a/schema/caching_options.cc b/schema/caching_options.cc index fe7fe44a1e..afae32a51d 100644 --- a/schema/caching_options.cc +++ b/schema/caching_options.cc @@ -77,14 +77,3 @@ caching_options caching_options::from_sstring(const sstring& str) { return from_map(rjson::parse_to_map>(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); -} diff --git a/schema/caching_options.hh b/schema/caching_options.hh index bdebc791ea..74af5c7bd7 100644 --- a/schema/caching_options.hh +++ b/schema/caching_options.hh @@ -42,9 +42,5 @@ public: static caching_options from_map(const std::map& 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; }; - - - diff --git a/schema/schema.cc b/schema/schema.cc index 958beb0614..670ec9a72f 100644 --- a/schema/schema.cc +++ b/schema/schema.cc @@ -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()) { diff --git a/schema/schema.hh b/schema/schema.hh index e84fa6b93d..7615711fea 100644 --- a/schema/schema.hh +++ b/schema/schema.hh @@ -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 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. // diff --git a/schema_mutations.cc b/schema_mutations.cc index 1a872a4847..02ce9a643d 100644 --- a/schema_mutations.cc +++ b/schema_mutations.cc @@ -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) || diff --git a/schema_mutations.hh b/schema_mutations.hh index 6174399750..efc0c1a6dc 100644 --- a/schema_mutations.hh +++ b/schema_mutations.hh @@ -128,7 +128,6 @@ public: std::optional 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 diff --git a/serializer.hh b/serializer.hh index f26701f9bb..867d3068e7 100644 --- a/serializer.hh +++ b/serializer.hh @@ -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; diff --git a/service/qos/qos_common.hh b/service/qos/qos_common.hh index bbf8dd3a22..88cd9f153d 100644 --- a/service/qos/qos_common.hh +++ b/service/qos/qos_common.hh @@ -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 parse_workload_type(std::string_view sv); diff --git a/sstables/compress.hh b/sstables/compress.hh index d4b9ef1ea1..37688cfae3 100644 --- a/sstables/compress.hh +++ b/sstables/compress.hh @@ -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; } diff --git a/sstables/consumer.hh b/sstables/consumer.hh index a46325700e..4b9582052e 100644 --- a/sstables/consumer.hh +++ b/sstables/consumer.hh @@ -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. diff --git a/sstables/mx/bsearch_clustered_cursor.hh b/sstables/mx/bsearch_clustered_cursor.hh index d1a35b5b87..856c608394 100644 --- a/sstables/mx/bsearch_clustered_cursor.hh +++ b/sstables/mx/bsearch_clustered_cursor.hh @@ -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 diff --git a/sstables/types.hh b/sstables/types.hh index 92e285f9ee..5ba10673ce 100644 --- a/sstables/types.hh +++ b/sstables/types.hh @@ -71,13 +71,7 @@ struct deletion_time { (marked_for_delete_at == std::numeric_limits::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(); } diff --git a/streaming/stream_manager.hh b/streaming/stream_manager.hh index c2724b84fe..c3afd4ffba 100644 --- a/streaming/stream_manager.hh +++ b/streaming/stream_manager.hh @@ -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; diff --git a/test/boost/double_decker_test.cc b/test/boost/double_decker_test.cc index b4c7cb3510..4378f5ac0d 100644 --- a/test/boost/double_decker_test.cc +++ b/test/boost/double_decker_test.cc @@ -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; } diff --git a/test/boost/service_level_controller_test.cc b/test/boost/service_level_controller_test.cc index 6482f7dcd3..6ecfaac22e 100644 --- a/test/boost/service_level_controller_test.cc +++ b/test/boost/service_level_controller_test.cc @@ -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; diff --git a/test/boost/small_vector_test.cc b/test/boost/small_vector_test.cc index b435531ab0..9590fd0fbd 100644 --- a/test/boost/small_vector_test.cc +++ b/test/boost/small_vector_test.cc @@ -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 diff --git a/tombstone_gc_options.cc b/tombstone_gc_options.cc index fe7871fff2..3da0ae1ff6 100644 --- a/tombstone_gc_options.cc +++ b/tombstone_gc_options.cc @@ -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"; diff --git a/tombstone_gc_options.hh b/tombstone_gc_options.hh index 95627d8fe7..3594e6f08f 100644 --- a/tombstone_gc_options.hh +++ b/tombstone_gc_options.hh @@ -27,8 +27,7 @@ public: } std::map 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); diff --git a/types/listlike_partial_deserializing_iterator.hh b/types/listlike_partial_deserializing_iterator.hh index c35692461c..6426664ebd 100644 --- a/types/listlike_partial_deserializing_iterator.hh +++ b/types/listlike_partial_deserializing_iterator.hh @@ -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 }; } diff --git a/types/tuple.hh b/types/tuple.hh index cc065a335a..e2dd0c9230 100644 --- a/types/tuple.hh +++ b/types/tuple.hh @@ -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; diff --git a/types/types.hh b/types/types.hh index ae3c0a6b19..bef59c8c7e 100644 --- a/types/types.hh +++ b/types/types.hh @@ -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; using managed_bytes_view_opt = std::optional; diff --git a/utils/anchorless_list.hh b/utils/anchorless_list.hh index 731245630b..84f4b14e19 100644 --- a/utils/anchorless_list.hh +++ b/utils/anchorless_list.hh @@ -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 @@ -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 { diff --git a/utils/bptree.hh b/utils/bptree.hh index 53608bf27c..42a53c3e45 100644 --- a/utils/bptree.hh +++ b/utils/bptree.hh @@ -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; diff --git a/utils/chunked_vector.hh b/utils/chunked_vector.hh index 932888332c..1990c287db 100644 --- a/utils/chunked_vector.hh +++ b/utils/chunked_vector.hh @@ -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); - } }; diff --git a/utils/compact-radix-tree.hh b/utils/compact-radix-tree.hh index d983692646..8567092883 100644 --- a/utils/compact-radix-tree.hh +++ b/utils/compact-radix-tree.hh @@ -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; diff --git a/utils/double-decker.hh b/utils/double-decker.hh index 8a75f36568..9f07de00ee 100644 --- a/utils/double-decker.hh +++ b/utils/double-decker.hh @@ -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; diff --git a/utils/fragmented_temporary_buffer.hh b/utils/fragmented_temporary_buffer.hh index 268ff51b76..98eabb1ea4 100644 --- a/utils/fragmented_temporary_buffer.hh +++ b/utils/fragmented_temporary_buffer.hh @@ -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); static_assert(FragmentedView); diff --git a/utils/intrusive_btree.hh b/utils/intrusive_btree.hh index 0e7d2aaf5e..e4c6c8cbcf 100644 --- a/utils/intrusive_btree.hh +++ b/utils/intrusive_btree.hh @@ -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(); } /* diff --git a/utils/loading_cache.hh b/utils/loading_cache.hh index eaf871d2da..02490c56b7 100644 --- a/utils/loading_cache.hh +++ b/utils/loading_cache.hh @@ -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(); } diff --git a/utils/loading_shared_values.hh b/utils/loading_shared_values.hh index e12b47b75b..30c30aa089 100644 --- a/utils/loading_shared_values.hh +++ b/utils/loading_shared_values.hh @@ -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(); } diff --git a/utils/log_heap.hh b/utils/log_heap.hh index 64ee35bdf0..f9a2f3e141 100644 --- a/utils/log_heap.hh +++ b/utils/log_heap.hh @@ -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; using const_iterator = hist_iterator; diff --git a/utils/lsa/chunked_managed_vector.hh b/utils/lsa/chunked_managed_vector.hh index 31863bbaa7..a0aaae48b0 100644 --- a/utils/lsa/chunked_managed_vector.hh +++ b/utils/lsa/chunked_managed_vector.hh @@ -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. diff --git a/utils/lsa/weak_ptr.hh b/utils/lsa/weak_ptr.hh index f224bc8695..aef298f7ef 100644 --- a/utils/lsa/weak_ptr.hh +++ b/utils/lsa/weak_ptr.hh @@ -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 { diff --git a/utils/managed_bytes.hh b/utils/managed_bytes.hh index 0ff88b6627..2243d1294f 100644 --- a/utils/managed_bytes.hh +++ b/utils/managed_bytes.hh @@ -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); } diff --git a/utils/multiprecision_int.hh b/utils/multiprecision_int.hh index 117a524afb..cc689a2c99 100644 --- a/utils/multiprecision_int.hh +++ b/utils/multiprecision_int.hh @@ -10,6 +10,7 @@ #include #include +#include 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 bool operator==(const T& x) const { return _v == maybe_unwrap(x); } template - bool operator!=(const T& x) const { - return _v != maybe_unwrap(x); - } - template 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 - friend bool operator==(const T& x, const multiprecision_int& y) { - return maybe_unwrap(x) == y._v; - } - template - friend bool operator!=(const T& x, const multiprecision_int& y) { - return maybe_unwrap(x) != y._v; - } - template - friend bool operator>(const T& x, const multiprecision_int& y) { - return maybe_unwrap(x) > y._v; - } - template - friend bool operator>=(const T& x, const multiprecision_int& y) { - return maybe_unwrap(x) >= y._v; - } - template - friend bool operator<(const T& x, const multiprecision_int& y) { - return maybe_unwrap(x) < y._v; - } - template - 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); }; diff --git a/version.hh b/version.hh index c29f00ea24..809ea5b6e1 100644 --- a/version.hh +++ b/version.hh @@ -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() {