|
Boost : |
Subject: Re: [boost] Alternative implementation for BOOST_PP_VARIADIC_SIZE
From: Edward Diener (eldiener_at_[hidden])
Date: 2011-11-13 22:41:22
On 11/13/2011 9:48 PM, Gennadiy Rozental wrote:
> Edward Diener<eldiener<at> tropicsoft.com> writes:
>
>> the page. My comment is:
>>
>> "#define AMACRO(x) ()
>> IS_EMPTY(AMACRO) is true, where of course it should be false.
>
> Are you sure? My gcc (cygwin) says it false.
I admit I do not understand how this can be. in the expansion to the
code on that page it sure looks to me like
'HAS_COMMA(_TRIGGER_PARENTHESIS_ __VA_ARGS__ (~))' will equate to 1 when
__VA_ARGS__ = AMACRO since 'AMACRO (~)' = '()', '_TRIGGER_PARENTHESIS_
()' = ',', and HAS_COMMA(,) = 1.
I will look at it in Wave, which I trust more than most anything as a
preprocessor.
>
> On the other hand if you define it like this:
>
> #define AMACRO(x,y) anything here
>
> if fails to build.
>
> In any case, as I said previous, this is corner case we should just document,
> but size should return zero when we actually did not pass any arguments to the
> macro.
I did document this corner case in my VMD but clearly it makes an
IS_EMPTY macro not 100% reliable, as it makes your solution not 100%
reliable. It is no use saying that you have a foolproof solution to size
returning 0, when it is clearly not foolproof. OTOH I personally am not
against having a solution that is not 100% reliable else I would not
have put out the latest version of VMD. But, although I can not speak
for him, I have a strong impression that Paul does not want such code in
Boost PP.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk