preprocessor: add COUNT_MAP

This commit is contained in:
Danny Robson 2021-02-02 11:41:26 +10:00
parent d736ecf6e6
commit 3416442dda
1 changed files with 4 additions and 0 deletions

View File

@ -168,6 +168,10 @@ if __name__ == '__main__':
#define APPEND_COMMA(X) X,
#define ONE_PLUS(ARG) 1+
/// Given the functional macro `FUNC`, that applies some macro to a list of
/// elements, find the number of elements in `FUNC`.
#define COUNT_MAP(FUNC) (FUNC(ONE_PLUS)+0)
#define STRINGIZE_DETAIL(x) #x
#define STRINGIZE(x) STRINGIZE_DETAIL(x)