18 lines
1.1 KiB
C++
18 lines
1.1 KiB
C++
|
#pragma once
|
||
|
|
||
|
// https://stackoverflow.com/a/11994395 modified to fit my needs
|
||
|
#define FE_0(WHAT)
|
||
|
#define FE_1(WHAT, extra_arg, X) WHAT(extra_arg, X)
|
||
|
#define FE_2(WHAT, extra_arg, X, ...) WHAT(extra_arg, X)FE_1(WHAT, extra_arg, __VA_ARGS__)
|
||
|
#define FE_3(WHAT, extra_arg, X, ...) WHAT(extra_arg, X)FE_2(WHAT, extra_arg, __VA_ARGS__)
|
||
|
#define FE_4(WHAT, extra_arg, X, ...) WHAT(extra_arg, X)FE_3(WHAT, extra_arg, __VA_ARGS__)
|
||
|
#define FE_5(WHAT, extra_arg, X, ...) WHAT(extra_arg, X)FE_4(WHAT, extra_arg, __VA_ARGS__)
|
||
|
#define FE_6(WHAT, extra_arg, X, ...) WHAT(extra_arg, X)FE_5(WHAT, extra_arg, __VA_ARGS__)
|
||
|
#define FE_7(WHAT, extra_arg, X, ...) WHAT(extra_arg, X)FE_6(WHAT, extra_arg, __VA_ARGS__)
|
||
|
#define FE_8(WHAT, extra_arg, X, ...) WHAT(extra_arg, X)FE_7(WHAT, extra_arg, __VA_ARGS__)
|
||
|
#define FE_9(WHAT, extra_arg, X, ...) WHAT(extra_arg, X)FE_8(WHAT, extra_arg, __VA_ARGS__)
|
||
|
|
||
|
#define GET_MACRO(_0,_1,_2,_3,_4,_5,_6,_7,_8,_9,NAME,...) NAME
|
||
|
#define FOR_EACH(action,extra_arg,...) \
|
||
|
GET_MACRO(_0,__VA_ARGS__,FE_9,FE_8,FE_7,FE_6,FE_5,FE_4,FE_3,FE_2,FE_1,FE_0)(action,extra_arg,__VA_ARGS__)
|