the default-generated comparison operators can fulfill our needs.
Signed-off-by: Kefu Chai <tchaikov@gmail.com>
/*
* macros to define comparison operators for classes with small numbers of members.
*/
-#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; \
- } \
- inline bool operator!=(const type &l, const type &r) { \
- return l.a != r.a || l.b != r.b || l.c != r.c; \
- }
-
-#define WRITE_CMP_OPERATORS_3(type, a, b, c) \
- inline bool operator>(const type &l, const type &r) { \
- return l.a > r.a || \
- (l.a == r.a && (l.b > r.b || \
- (l.b == r.b && (l.c > r.c)))); \
- } \
- inline bool operator<(const type &l, const type &r) { \
- return l.a < r.a || \
- (l.a == r.a && (l.b < r.b || \
- (l.b == r.b && (l.c < r.c)))); \
- } \
- inline bool operator>=(const type &l, const type &r) { \
- return l.a > r.a || \
- (l.a == r.a && (l.b > r.b || \
- (l.b == r.b && (l.c >= r.c)))); \
- } \
- inline bool operator<=(const type &l, const type &r) { \
- return l.a < r.a || \
- (l.a == r.a && (l.b < r.b || \
- (l.b == r.b && (l.c <= r.c)))); \
- }
-
#define WRITE_EQ_OPERATORS_4(type, a, b, c, d) \
inline bool operator==(const type &l, const type &r) { \
return l.a == r.a && l.b == r.b && l.c == r.c && l.d == r.d; \
#include <string>
#include <include/rados/librados.hpp>
-#include "include/cmp.h"
-
namespace librados {
struct ListObjectImpl {
std::string nspace;
ListObjectImpl(std::string n, std::string o, std::string l):
nspace(n), oid(o), locator(l) {}
+ auto operator<=>(const ListObjectImpl&) const = default;
+
const std::string& get_nspace() const { return nspace; }
const std::string& get_oid() const { return oid; }
const std::string& get_locator() const { return locator; }
};
-WRITE_EQ_OPERATORS_3(ListObjectImpl, nspace, oid, locator)
-WRITE_CMP_OPERATORS_3(ListObjectImpl, nspace, oid, locator)
inline std::ostream& operator<<(std::ostream& out, const struct ListObjectImpl& lop) {
out << (lop.nspace.size() ? lop.nspace + "/" : "") << lop.oid
<< (lop.locator.size() ? "@" + lop.locator : "");
#define __CEPH_OS_SEQUENCERPOSITION_H
#include "include/types.h"
-#include "include/cmp.h"
#include "include/encoding.h"
#include "common/Formatter.h"
SequencerPosition(uint64_t s=0, int32_t t=0, int32_t o=0) : seq(s), trans(t), op(o) {}
+ auto operator<=>(const SequencerPosition&) const = default;
+
void encode(ceph::buffer::list& bl) const {
ENCODE_START(1, 1, bl);
encode(seq, bl);
return out << t.seq << "." << t.trans << "." << t.op;
}
-WRITE_EQ_OPERATORS_3(SequencerPosition, seq, trans, op)
-WRITE_CMP_OPERATORS_3(SequencerPosition, seq, trans, op)
-
-
#endif