From: Loic Dachary Date: Wed, 28 May 2014 12:53:47 +0000 (+0200) Subject: common: WRITE_{EQ,CMP}_OPERATORS_1 X-Git-Tag: v0.83~136^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=6786d60917ac67cac570e5e7c4a3db6d91a3121f;p=ceph.git common: WRITE_{EQ,CMP}_OPERATORS_1 For when a struct is defined to encapsulate a single value and get control over implicit conversions that would otherwise be impossible with typedef. Signed-off-by: Loic Dachary --- diff --git a/src/include/cmp.h b/src/include/cmp.h index 92ecef47990..93365bf6ac6 100644 --- a/src/include/cmp.h +++ b/src/include/cmp.h @@ -5,6 +5,28 @@ * macros to define comparison operators for classes with small numbers of members. */ +#define WRITE_EQ_OPERATORS_1(type, a) \ + inline bool operator==(const type &l, const type &r) { \ + return l.a == r.a; \ + } \ + inline bool operator!=(const type &l, const type &r) { \ + return l.a != r.a; \ + } + +#define WRITE_CMP_OPERATORS_1(type, a) \ + inline bool operator>(const type &l, const type &r) { \ + return l.a > r.a; \ + } \ + inline bool operator<(const type &l, const type &r) { \ + return l.a < r.a; \ + } \ + inline bool operator>=(const type &l, const type &r) { \ + return l.a >= r.a; \ + } \ + inline bool operator<=(const type &l, const type &r) { \ + return l.a <= r.a; \ + } + #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; \