Boost logo

Boost :

Subject: Re: [boost] [PREPROCESSOR] Possible improvement for BOOST_PP_VARIADIC_SIZE
From: Edward Diener (eldiener_at_[hidden])
Date: 2013-09-09 22:47:59


On 9/9/2013 4:44 PM, Brent Lewis wrote:
> Currently,
>
> BOOST_VARIADIC_SIZE()
>
> evaluates to 1. Based on
> http://gustedt.wordpress.com/2010/06/08/detect-empty-macro-arguments/ it
> can be improved to return 0 for an empty argument list.

The flaw in the detection of empty arguments in the above link has
already been discussed. I am not putting down that implementation in
saying so.

It is impossible to perfectly detect an empty argument. IMO the best
case for detecting an empty argument was an example by Paul Mensonides
on the web which I adapted for my VMD library at
https://github.com/eldiener/variadic_macro_data.git.

Furthermore as Paul has pointed out even an "empty" argument is
considered an argument and still counts as 1 for the variadic size. In
fact the spec for a variadic macro says that you cannot pass no argument
when the macro expects variadic data. In other words:

#define AVAR(ARG,...)

AVAR(something)

is an error, but of course

AVAR(something,)

or

#define AVARAG(...)

AVARAG()

is perfectly fine since you are indeed passing an argument even if it is
an "empty" argument.


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