Boost logo

Boost Users :

From: Manuel Jung (gzahl_at_[hidden])
Date: 2007-06-24 03:31:27


Hi

Thanks for your explanations. I'll need a moment to understand and read
more. Maybe i'll be back here then. But thanks a lot for this!
Greetings
Manuel Jung

> Manuel Jung wrote:
>> Hi
>>
>> The BOOST_PP_SEQ_PUSH_BACK Macro expands to the seq with the extra
>> element. But i don't want it to expand.
>
> So if the macro wouldn't expand it stays BOOST_PP_SEQ_PUSH_BACK(foo,bar)
> (literally), which obviously is not a sequence...
>
>> I want to use the sequence later instead.
>
> Just do so (I'm not sure I understand what you're up to)!
> BOOST_PP_SEQ_PUSH_BACK is a trivial macro mostly for completeness:
> Instead of
>
> BOOST_PP_SEQ_PUSH_BACK(SEQ, c)
>
> you might as well say:
>
> SEQ (c)
>
> (subtle differences omitted, not to cause total confusion).
>
>> How can i supress the expanding?
>
> As it's the very nature of the preprocessor to expand all macro
> invocations it sees, you can't in general.
>
> You can delay the expansion of function-like macros by supplying the
> argument list at a later point,
>
> #define MACRO(optional) foo optional() baz
>
> MACRO(BOOST_PP_EMPTY) // foo baz
> MACRO(BOOST_PP_IDENTITY(bar)) // foo bar baz
>
> // BTW: this techniques is used to avoid empty macro arguments
> // which provoke undefined behavior with C++98
>
> or making sure it's connected at a later point:
>
> #define E() // Empty
> #define X(x) x // eXpand
>
> MACRO E () (BOOST_PP_EMPTY) // MACRO (BOOST_PP_EMPTY)
>
> X( MACRO E () (BOOST_PP_EMPTY) ) // foo baz
> X( MACRO E E () () (BOOST_PP_EMPTY) ) // MACRO (BOOST_PP_EMPTY)
> X(X( MACRO E E () () (BOOST_PP_EMPTY) )) // foo baz
>
> .
>
>> I'm new too Preprocessorprogramming, so please excuse, if my question is
>> stupid. Not the easiest thing, starting Preprocessor and Metaprogramming
>> from nothing but the docs.
>
> Search the list archives, there should be lots of good material, around.
>
> http://news.gmane.org/gmane.comp.lib.boost.user
> http://news.gmane.org/gmane.comp.lib.boost.devel
>
> Regards,
> Tobias


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