2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

[備忘録]マクロのforeach

Last updated at Posted at 2020-11-02

はじめに

ただの備忘録です。
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__)

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?