|
Boost Users : |
Subject: Re: [Boost-users] [preprocessor] Is there an equivalent of "delayed expansion"?
From: pfultz2 (pfultz2_at_[hidden])
Date: 2013-04-15 08:42:59
> 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-delayed-expansion-tp4645346p4645387.html Sent from the Boost - Users mailing list archive at Nabble.com.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net