[preprocessor] BOOST_PP_IF with BOOST_PP_SEQ_ENUM as then-argument
Hello! #define seq (int)(int) BOOST_PP_IF(1, BOOST_PP_SEQ_ENUM(seq), BOOST_PP_EMTPY) does not expand to what i want: it should be int, int . G++ gives the following error: test.cpp:20:1: macro "BOOST_PP_IIF" passed 4 arguments, but takes just 3 BOOST_PP_IIF which is logical, because SEQ_ENUM expands to int, int and so if gets 4 arguments. I tried to surround SEQ_ENUM with IDENTITY but it's the same problem. Only surrounding SEQ_ENUM with () works, but then I have the () in the code, which I do not want. How can I solve this problem? Max
Quoting Maximilian Matthe
Hello!
#define seq (int)(int)
BOOST_PP_IF(1, BOOST_PP_SEQ_ENUM(seq), BOOST_PP_EMTPY)
does not expand to what i want: it should be int, int . G++ gives the following error:
test.cpp:20:1: macro "BOOST_PP_IIF" passed 4 arguments, but takes just 3 BOOST_PP_IIF
which is logical, because SEQ_ENUM expands to int, int and so if gets 4 arguments. I tried to surround SEQ_ENUM with IDENTITY but it's the same problem. Only surrounding SEQ_ENUM with () works, but then I have the () in the code, which I do not want. How can I solve this problem?
Max
You need to delay the evaluation of the SEQ_ENUM til after the IF: #define DO_NOTHING(seq) BOOST_PP_IF(1, BOOST_PP_SEQ_ENUM , DO_NOTHING)()
Peter Bartlett schrieb:
Quoting Maximilian Matthe
: Hello!
#define seq (int)(int)
BOOST_PP_IF(1, BOOST_PP_SEQ_ENUM(seq), BOOST_PP_EMTPY)
does not expand to what i want: it should be int, int . G++ gives the following error:
test.cpp:20:1: macro "BOOST_PP_IIF" passed 4 arguments, but takes just 3 BOOST_PP_IIF
which is logical, because SEQ_ENUM expands to int, int and so if gets 4 arguments. I tried to surround SEQ_ENUM with IDENTITY but it's the same problem. Only surrounding SEQ_ENUM with () works, but then I have the () in the code, which I do not want. How can I solve this problem?
Max
You need to delay the evaluation of the SEQ_ENUM til after the IF:
#define DO_NOTHING(seq)
BOOST_PP_IF(1, BOOST_PP_SEQ_ENUM , DO_NOTHING)()
Ah thank you. This is quite tricky :-)
Quoting Maximilian Matthe
Peter Bartlett schrieb:
Quoting Maximilian Matthe
: Hello!
#define seq (int)(int)
BOOST_PP_IF(1, BOOST_PP_SEQ_ENUM(seq), BOOST_PP_EMTPY)
does not expand to what i want: it should be int, int . G++ gives the following error:
test.cpp:20:1: macro "BOOST_PP_IIF" passed 4 arguments, but takes just 3 BOOST_PP_IIF
which is logical, because SEQ_ENUM expands to int, int and so if gets 4 arguments. I tried to surround SEQ_ENUM with IDENTITY but it's the same problem. Only surrounding SEQ_ENUM with () works, but then I have the () in the code, which I do not want. How can I solve this problem?
Max
You need to delay the evaluation of the SEQ_ENUM til after the IF:
#define DO_NOTHING(seq)
BOOST_PP_IF(1, BOOST_PP_SEQ_ENUM , DO_NOTHING)()
Ah thank you. This is quite tricky :-)
Sorry there was a typo in my post: BOOST_PP_IF(1, BOOST_PP_SEQ_ENUM , DO_NOTHING)() should've been BOOST_PP_IF(1, BOOST_PP_SEQ_ENUM , DO_NOTHING)(seq)
Peter Bartlett schrieb:
Quoting Maximilian Matthe
: Peter Bartlett schrieb:
Quoting Maximilian Matthe
: Hello!
#define seq (int)(int)
BOOST_PP_IF(1, BOOST_PP_SEQ_ENUM(seq), BOOST_PP_EMTPY)
does not expand to what i want: it should be int, int . G++ gives the following error:
test.cpp:20:1: macro "BOOST_PP_IIF" passed 4 arguments, but takes just 3 BOOST_PP_IIF
which is logical, because SEQ_ENUM expands to int, int and so if gets 4 arguments. I tried to surround SEQ_ENUM with IDENTITY but it's the same problem. Only surrounding SEQ_ENUM with () works, but then I have the () in the code, which I do not want. How can I solve this problem?
Max
You need to delay the evaluation of the SEQ_ENUM til after the IF:
#define DO_NOTHING(seq)
BOOST_PP_IF(1, BOOST_PP_SEQ_ENUM , DO_NOTHING)()
Ah thank you. This is quite tricky :-)
Sorry there was a typo in my post:
BOOST_PP_IF(1, BOOST_PP_SEQ_ENUM , DO_NOTHING)()
should've been
BOOST_PP_IF(1, BOOST_PP_SEQ_ENUM , DO_NOTHING)(seq) Yes, I've realized that before. Thank you
participants (2)
-
Maximilian Matthe
-
Peter Bartlett