the default-generated comparison operators can fulfill our needs.
Signed-off-by: Kefu Chai <tchaikov@gmail.com>
friend bool operator<(const EntityName& a, const EntityName& b);
friend std::ostream& operator<<(std::ostream& out, const EntityName& n);
- friend bool operator==(const EntityName& a, const EntityName& b);
- friend bool operator!=(const EntityName& a, const EntityName& b);
+
+ bool operator==(const EntityName& rhs) const noexcept {
+ return type == rhs.type && id == rhs.id;
+ }
private:
struct str_to_entity_type_t {
WRITE_CLASS_ENCODER(EntityName)
-WRITE_EQ_OPERATORS_2(EntityName, type, id)
-
#endif
/*
* macros to define comparison operators for classes with small numbers of members.
*/
-
-#define WRITE_EQ_OPERATORS_2(type, a, b) \
- inline bool operator==(const type &l, const type &r) { \
- return l.a == r.a && l.b == r.b; \
- } \
- inline bool operator!=(const type &l, const type &r) { \
- return l.a != r.a || l.b != r.b; \
- }
-
-#define WRITE_CMP_OPERATORS_2(type, a, b) \
- inline bool operator>(const type &l, const type &r) { \
- return l.a > r.a || \
- (l.a == r.a && (l.b > r.b)); \
- } \
- inline bool operator<(const type &l, const type &r) { \
- return l.a < r.a || \
- (l.a == r.a && (l.b < r.b)); \
- } \
- inline bool operator>=(const type &l, const type &r) { \
- return l.a > r.a || \
- (l.a == r.a && (l.b >= r.b)); \
- } \
- inline bool operator<=(const type &l, const type &r) { \
- return l.a < r.a || \
- (l.a == r.a && (l.b <= r.b)); \
- }
-
-
#define WRITE_EQ_OPERATORS_3(type, a, b, c) \
inline bool operator==(const type &l, const type &r) { \
return l.a == r.a && l.b == r.b && l.c == r.c; \
#include "common/snap_types.h"
#include "HitSet.h"
#include "Watch.h"
-#include "include/cmp.h"
#include "librados/ListObjectImpl.h"
#include "compressor/Compressor.h"
#include "osd_perf_counters.h"
f->dump_unsigned("shard", shard);
}
}
+ auto operator<=>(const pg_shard_t&) const = default;
};
WRITE_CLASS_ENCODER(pg_shard_t)
-WRITE_EQ_OPERATORS_2(pg_shard_t, osd, shard)
-WRITE_CMP_OPERATORS_2(pg_shard_t, osd, shard)
std::ostream& operator<<(std::ostream &lhs, const pg_shard_t &rhs);
using HobjToShardSetMapping = std::map<hobject_t, std::set<pg_shard_t>>;
spg_t() : shard(shard_id_t::NO_SHARD) {}
spg_t(pg_t pgid, shard_id_t shard) : pgid(pgid), shard(shard) {}
explicit spg_t(pg_t pgid) : pgid(pgid), shard(shard_id_t::NO_SHARD) {}
+ auto operator<=>(const spg_t&) const = default;
unsigned get_split_bits(unsigned pg_num) const {
return pgid.get_split_bits(pg_num);
}
}
};
WRITE_CLASS_ENCODER(spg_t)
-WRITE_EQ_OPERATORS_2(spg_t, pgid, shard)
-WRITE_CMP_OPERATORS_2(spg_t, pgid, shard)
namespace std {
template<> struct hash< spg_t >
#include "osd/scheduler/OpScheduler.h"
#include "common/config.h"
-#include "include/cmp.h"
#include "common/ceph_context.h"
#include "common/mClockPriorityQueue.h"
#include "osd/scheduler/OpSchedulerItem.h"
client_id_t client_id;
profile_id_t profile_id;
+ auto operator<=>(const client_profile_id_t&) const = default;
friend std::ostream& operator<<(std::ostream& out,
const client_profile_id_t& client_profile) {
out << " client_id: " << client_profile.client_id
}
};
-WRITE_EQ_OPERATORS_2(client_profile_id_t, client_id, profile_id)
-WRITE_CMP_OPERATORS_2(client_profile_id_t, client_id, profile_id)
-
-
struct scheduler_id_t {
op_scheduler_class class_id;
client_profile_id_t client_profile_id;
+ auto operator<=>(const scheduler_id_t&) const = default;
friend std::ostream& operator<<(std::ostream& out,
const scheduler_id_t& sched_id) {
out << "{ class_id: " << sched_id.class_id
}
};
-WRITE_EQ_OPERATORS_2(scheduler_id_t, class_id, client_profile_id)
-WRITE_CMP_OPERATORS_2(scheduler_id_t, class_id, client_profile_id)
-
/**
* Scheduler implementation based on mclock.
*