|
Boost Users : |
Subject: Re: [Boost-users] [preprocessor] BOOST_PP_VARIADIC_SIZE() and g++ in 1.52
From: Nat Linden (nat_at_[hidden])
Date: 2012-12-12 11:18:30
On Tue, Dec 11, 2012 at 11:16 PM, Nathan Ridge <zeratul976_at_[hidden]> wrote:
> > In fact, when I change the definition of the intercept() macro below to:
> >
> > #define intercept(FIRST, ARGS...) \
> > targetfunc(transform(FIRST) \
> > , boost::lexical_cast<std::string>(BOOST_PP_VARIADIC_SIZE(ARGS)))
> >
> > I see that BOOST_PP_VARIADIC_SIZE() expands to 1 for
> > intercept("first") as well as for intercept("first", "second").
> As I understand it, it is impossible to reliably detect an empty
> argument list in all cases, so BOOST_PP_VARIADIC_SIZE() returns
> 1 for an empty argument list. Take a look at this thread [1] for
> an explanation and a workaround.
Hmm, am I trying to solve the wrong problem?
The briefest explanation of what I want is to take a macro argument
list with zero or more arguments and construct a function argument
list with one more (initial) argument than that.
I just need MACRO() to expand to function(first), but MACRO(anything)
to expand to function(first, anything).
Is there some more reliable way than
BOOST_PP_COMMA_IF(BOOST_PP_VARIADIC_SIZE()) to make the comma appear
only when required?
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