Nix 2.36.0
Nix, the purely functional package manager; unstable internal interfaces
Loading...
Searching...
No Matches
comparator.hh
Go to the documentation of this file.
1#pragma once
3
4#define GENERATE_ONE_CMP(PRE, RET, QUAL, COMPARATOR, MY_TYPE, ...) \
5 PRE RET QUAL operator COMPARATOR(const MY_TYPE & other) const noexcept \
6 { \
7 __VA_OPT__(const MY_TYPE * me = this;) \
8 auto fields1 = std::tie(__VA_ARGS__); \
9 __VA_OPT__(me = &other;) \
10 auto fields2 = std::tie(__VA_ARGS__); \
11 return fields1 COMPARATOR fields2; \
12 }
13#define GENERATE_EQUAL(prefix, qualification, my_type, args...) \
14 GENERATE_ONE_CMP(prefix, bool, qualification, ==, my_type, args)
15#define GENERATE_SPACESHIP(prefix, ret, qualification, my_type, args...) \
16 GENERATE_ONE_CMP(prefix, ret, qualification, <=>, my_type, args)
17
39#define GENERATE_CMP(args...) \
40 GENERATE_EQUAL(, , args) \
41 GENERATE_SPACESHIP(, auto, , args)
42
49#define GENERATE_CMP_EXT(prefix, ret, my_type, args...) \
50 GENERATE_EQUAL(prefix, my_type ::, my_type, args) \
51 GENERATE_SPACESHIP(prefix, ret, my_type ::, my_type, args)