はじめに
ただの備忘録です。
BoostPPとか使うの面倒くさい時にすぐ使える用
PP_FOREACH
#define PP_FOREACH_1(macro,e1) macro(e1)
#define PP_FOREACH_2(macro,e1,...) macro(e1), PP_FOREACH_1(macro,__VA_ARGS__)
#define PP_FOREACH_3(macro,e1,...) macro(e1), PP_FOREACH_2(macro,__VA_ARGS__)
#define PP_FOREACH_4(macro,e1,...) macro(e1), PP_FOREACH_3(macro,__VA_ARGS__)
#define PP_FOREACH_5(macro,e1,...) macro(e1), PP_FOREACH_4(macro,__VA_ARGS__)
#define PP_FOREACH_6(macro,e1,...) macro(e1), PP_FOREACH_5(macro,__VA_ARGS__)
#define PP_FOREACH_7(macro,e1,...) macro(e1), PP_FOREACH_6(macro,__VA_ARGS__)
#define PP_FOREACH_8(macro,e1,...) macro(e1), PP_FOREACH_7(macro,__VA_ARGS__)
#define PP_FOREACH_9(macro,e1,...) macro(e1), PP_FOREACH_8(macro,__VA_ARGS__)
#define PP_FOREACH_10(macro,e1,...) macro(e1), PP_FOREACH_9(macro,__VA_ARGS__)
// 必要次第追加
#define PP_GET_FOREACH(e1,e2,e3,e4,e5,e6,e7,e8,e9,e10,NAME,...) NAME
#define PP_FOREACH(macro,...) PP_GET_FOREACH(__VA_ARGS__,PP_FOREACH_10,PP_FOREACH_9,PP_FOREACH_8,PP_FOREACH_7,PP_FOREACH_6,PP_FOREACH_5,PP_FOREACH_4,PP_FOREACH_3,PP_FOREACH_2,PP_FOR_EACH1)(macro, __VA_ARGS__)