| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
#pragma once |
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
#define _APPLY1(a, ...) a(__VA_ARGS__) |
| 9 |
#define _APPLY2(a, ...) a(__VA_ARGS__) |
| 10 |
#define _APPLY3(a, ...) a(__VA_ARGS__) |
| 11 |
#define _APPLY4(a, ...) a(__VA_ARGS__) |
| 12 |
|
| 13 |
#define RIOTA1(x) x |
| 14 |
#define RIOTA2(x) RIOTA1(x##1), RIOTA1(x##0) |
| 15 |
#define RIOTA4(x) RIOTA2(x##1), RIOTA2(x##0) |
| 16 |
#define RIOTA8(x) RIOTA4(x##1), RIOTA4(x##0) |
| 17 |
#define RIOTA16(x) RIOTA8(x##1), RIOTA8(x##0) |
| 18 |
|
| 19 |
#define RIOTA32(x) RIOTA16(x##1), RIOTA16(x##0) |
| 20 |
|
| 21 |
#define CONCAT2(a, b) a##b |
| 22 |
#define CONCAT1(a, b) CONCAT2(a, b) |
| 23 |
#define CONCAT(a, b) CONCAT1(a, b) |
| 24 |
|
| 25 |
#define _ARGS_HEAD(head, ...) head |
| 26 |
#define _ARGS_SKIP4(_1, _2, _3, _4, ...) __VA_ARGS__ |
| 27 |
#define _ARGS_SKIP8(...) _APPLY1(_ARGS_SKIP4, _ARGS_SKIP4(__VA_ARGS__)) |
| 28 |
#define _ARGS_SKIP16(...) _APPLY2(_ARGS_SKIP8, _ARGS_SKIP8(__VA_ARGS__)) |
| 29 |
#define _ARGS_SKIP32(...) _APPLY3(_ARGS_SKIP16, _ARGS_SKIP16(__VA_ARGS__)) |
| 30 |
|
| 31 |
|
| 32 |
#define _ARG33(...) _APPLY4(_ARGS_HEAD, _ARGS_SKIP32(__VA_ARGS__)) |
| 33 |
|
| 34 |
|
| 35 |
#define VA_ARGS_LENGTH(...) _ARG33(0, ##__VA_ARGS__, RIOTA32(0)) |
| 36 |
|
| 37 |
|
| 38 |
#define LIST_APPLY_000000(fn, sep, ...) |
| 39 |
#define LIST_APPLY_000001(fn, sep, x, ...) fn(x) |
| 40 |
#define LIST_APPLY_000010(fn, sep, x, ...) fn(x) sep() LIST_APPLY_000001(fn, sep, __VA_ARGS__) |
| 41 |
#define LIST_APPLY_000011(fn, sep, x, ...) fn(x) sep() LIST_APPLY_000010(fn, sep, __VA_ARGS__) |
| 42 |
#define LIST_APPLY_000100(fn, sep, x, ...) fn(x) sep() LIST_APPLY_000011(fn, sep, __VA_ARGS__) |
| 43 |
#define LIST_APPLY_000101(fn, sep, x, ...) fn(x) sep() LIST_APPLY_000100(fn, sep, __VA_ARGS__) |
| 44 |
#define LIST_APPLY_000110(fn, sep, x, ...) fn(x) sep() LIST_APPLY_000101(fn, sep, __VA_ARGS__) |
| 45 |
#define LIST_APPLY_000111(fn, sep, x, ...) fn(x) sep() LIST_APPLY_000110(fn, sep, __VA_ARGS__) |
| 46 |
#define LIST_APPLY_001000(fn, sep, x, ...) fn(x) sep() LIST_APPLY_000111(fn, sep, __VA_ARGS__) |
| 47 |
#define LIST_APPLY_001001(fn, sep, x, ...) fn(x) sep() LIST_APPLY_001000(fn, sep, __VA_ARGS__) |
| 48 |
#define LIST_APPLY_001010(fn, sep, x, ...) fn(x) sep() LIST_APPLY_001001(fn, sep, __VA_ARGS__) |
| 49 |
#define LIST_APPLY_001011(fn, sep, x, ...) fn(x) sep() LIST_APPLY_001010(fn, sep, __VA_ARGS__) |
| 50 |
#define LIST_APPLY_001100(fn, sep, x, ...) fn(x) sep() LIST_APPLY_001011(fn, sep, __VA_ARGS__) |
| 51 |
#define LIST_APPLY_001101(fn, sep, x, ...) fn(x) sep() LIST_APPLY_001100(fn, sep, __VA_ARGS__) |
| 52 |
#define LIST_APPLY_001110(fn, sep, x, ...) fn(x) sep() LIST_APPLY_001101(fn, sep, __VA_ARGS__) |
| 53 |
#define LIST_APPLY_001111(fn, sep, x, ...) fn(x) sep() LIST_APPLY_001110(fn, sep, __VA_ARGS__) |
| 54 |
#define LIST_APPLY_010000(fn, sep, x, ...) fn(x) sep() LIST_APPLY_001111(fn, sep, __VA_ARGS__) |
| 55 |
#define LIST_APPLY_010001(fn, sep, x, ...) fn(x) sep() LIST_APPLY_010000(fn, sep, __VA_ARGS__) |
| 56 |
#define LIST_APPLY_010010(fn, sep, x, ...) fn(x) sep() LIST_APPLY_010001(fn, sep, __VA_ARGS__) |
| 57 |
#define LIST_APPLY_010011(fn, sep, x, ...) fn(x) sep() LIST_APPLY_010010(fn, sep, __VA_ARGS__) |
| 58 |
#define LIST_APPLY_010100(fn, sep, x, ...) fn(x) sep() LIST_APPLY_010011(fn, sep, __VA_ARGS__) |
| 59 |
#define LIST_APPLY_010101(fn, sep, x, ...) fn(x) sep() LIST_APPLY_010100(fn, sep, __VA_ARGS__) |
| 60 |
#define LIST_APPLY_010110(fn, sep, x, ...) fn(x) sep() LIST_APPLY_010101(fn, sep, __VA_ARGS__) |
| 61 |
#define LIST_APPLY_010111(fn, sep, x, ...) fn(x) sep() LIST_APPLY_010110(fn, sep, __VA_ARGS__) |
| 62 |
#define LIST_APPLY_011000(fn, sep, x, ...) fn(x) sep() LIST_APPLY_010111(fn, sep, __VA_ARGS__) |
| 63 |
#define LIST_APPLY_011001(fn, sep, x, ...) fn(x) sep() LIST_APPLY_011000(fn, sep, __VA_ARGS__) |
| 64 |
#define LIST_APPLY_011010(fn, sep, x, ...) fn(x) sep() LIST_APPLY_011001(fn, sep, __VA_ARGS__) |
| 65 |
#define LIST_APPLY_011011(fn, sep, x, ...) fn(x) sep() LIST_APPLY_011010(fn, sep, __VA_ARGS__) |
| 66 |
#define LIST_APPLY_011100(fn, sep, x, ...) fn(x) sep() LIST_APPLY_011011(fn, sep, __VA_ARGS__) |
| 67 |
#define LIST_APPLY_011101(fn, sep, x, ...) fn(x) sep() LIST_APPLY_011100(fn, sep, __VA_ARGS__) |
| 68 |
#define LIST_APPLY_011110(fn, sep, x, ...) fn(x) sep() LIST_APPLY_011101(fn, sep, __VA_ARGS__) |
| 69 |
#define LIST_APPLY_011111(fn, sep, x, ...) fn(x) sep() LIST_APPLY_011110(fn, sep, __VA_ARGS__) |
| 70 |
#define LIST_APPLY_(N, fn, sep, ...) CONCAT(LIST_APPLY_, N)(fn, sep, __VA_ARGS__) |
| 71 |
#define LIST_APPLY(fn, sep, ...) LIST_APPLY_(VA_ARGS_LENGTH(__VA_ARGS__), fn, sep, __VA_ARGS__) |
| 72 |
|
| 73 |
|
| 74 |
#define SEP_COMMA() , |
| 75 |
#define SEP_COLON() ; |
| 76 |
#define SEP_NONE() |