Boost logo

Boost :

Subject: Re: [boost] Alternative implementation for BOOST_PP_VARIADIC_SIZE
From: Gennadiy Rozental (rogeeff_at_[hidden])
Date: 2011-11-12 06:52:33


Lorenzo Caminiti <lorcaminiti <at> gmail.com> writes:
> On Thu, Nov 10, 2011 at 6:43 PM, Gennadiy Rozental <rogeeff <at> gmail.com>>
> Hi,
> >
> > Current implementation of subject macro have a very serious shortcoming -
> > it does not work for empty __VA_ARGS__. After googling around a bit for
> > some ideas I came up with the following alternative:
>
> A while back there was a discussion about the
> possibility/impossibility to handle empty macro parameters using
> variadics:
>
> http://lists.boost.org/Archives/boost/2011/02/177321.php
>
> (Make sure to address the concerns expressed by Paul in the replies to
> the above thread.)

Frankly, I do not have time to read through the whole discussion. I am not a
language lawyer, but for what it worth my version works on all compilers I
have tried and looks to be perfectly legal (to me). I do know about one
limitation. It's where __VA_ARGS__ ends with macro function which produces
comma when evaluated. It's very rare case though and even if it's possible
to implement solution that deals with it (look here:
https://gustedt.wordpress.com/2010/06/08/detect-empty-macro-arguments/ ),
I find the complication does not worth the trouble.

If Edward or Paul care to comment it might be easier for them to point to any
shortcomings in my solution (if any).

Regards,
Gennadiy


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk