[preprocessor] Is there an equivalent of "delayed expansion"?

Is there an equivalent in boost for delaying the expansion of a macro? For example, I want EAT to act on TSEQ2, so I have to use trick on line 4. #define TSEQ2 (w)(x)(y)(z)(a)(b)(c)(d 2) #define IDENTITY(x) x #define EAT(x) IDENTITY(IDENTITY(EAT)TSEQ2) Thanks, Mostafa

Is there an equivalent in boost for delaying the expansion of a macro?
Im not quite sure what you are asking, in your example you aren't delaying the expansion of macro. The preprocessor works by scanning and expanding tokens. When it tries to expand `EAT TSEQ2`, it will see the `EAT` is a function macro, so it will check if the next token is an open parenthesis. However, it only sees `TSEQ2` and so it won't expand it. Then it moves to the next token, which is `TSEQ2` and sees that it is an object macro, so it expands that. So, you end up with this: EAT (w)(x)(y)(z)(a)(b)(c)(d 2) If you apply another scan to this it will work now, since `EAT` is now followed by an open parenthesis. You can use the `IDENTITY` macro you had to do that, all you need to write is this: IDENTITY(EAT TSEQ2) Boost does provide a `BOOST_PP_EXPAND` macro that can be used for this as well. It works the same as your `IDENTITY` macro. Thanks, Paul -- View this message in context: http://boost.2283326.n4.nabble.com/preprocessor-Is-there-an-equivalent-of-de... Sent from the Boost - Users mailing list archive at Nabble.com.

On Mon, 15 Apr 2013 05:42:59 -0700, pfultz2
Is there an equivalent in boost for delaying the expansion of a macro?
Im not quite sure what you are asking, in your example you aren't delaying the expansion of macro.
I think the correct term I was looking for was rescanning.
Boost does provide a `BOOST_PP_EXPAND` macro that can be used for this as well. It works the same as your `IDENTITY` macro.
Ah, thanks. That's what I was looking for. Mostafa
participants (2)
-
Mostafa
-
pfultz2