Derive-C
Loading...
Searching...
No Matches
ord.h
Go to the documentation of this file.
1#pragma once
2
3#include <stdbool.h>
4
7
8#define DC_TRAIT_ORDABLE(SELF) \
9 DC_REQUIRE_METHOD(bool, SELF, lt, (SELF const*, SELF const*)); \
10 DC_REQUIRE_METHOD(bool, SELF, gt, (SELF const*, SELF const*));
11
12#define _DC_DERIVE_ORD_MEMBER_GT(MEMBER_TYPE, MEMBER_NAME) \
13 || NS(MEMBER_TYPE, gt)(&self_1->MEMBER_NAME, &self_2->MEMBER_NAME)
14#define _DC_DERIVE_ORD_MEMBER_LT(MEMBER_TYPE, MEMBER_NAME) \
15 || NS(MEMBER_TYPE, lt)(&self_1->MEMBER_NAME, &self_2->MEMBER_NAME)
16
17#define DC_DERIVE_ORD(TYPE) \
18 static bool NS(TYPE, gt)(TYPE const* self_1, TYPE const* self_2) { \
19 return false NS(TYPE, REFLECT)(_DC_DERIVE_ORD_MEMBER_GT); \
20 } \
21 static bool NS(TYPE, lt)(TYPE const* self_1, TYPE const* self_2) { \
22 return false NS(TYPE, REFLECT)(_DC_DERIVE_ORD_MEMBER_LT); \
23 }
24
25#define _DC_DERIVE_STD_ORD(TYPE, ...) \
26 static bool NS(TYPE, gt)(TYPE const* self_1, TYPE const* self_2) { return *self_1 > *self_2; } \
27 static bool NS(TYPE, lt)(TYPE const* self_1, TYPE const* self_2) { return *self_1 < *self_2; }
28
#define _DC_DERIVE_STD_ORD(TYPE,...)
Definition ord.h:25
#define DC_STD_REFLECT(F,...)
Definition reflect.h:11