Boost logo

Boost Users :

From: Arkadiy Vertleyb (vertleyb_at_[hidden])
Date: 2006-10-06 15:24:30


"David Abrahams" <dave_at_[hidden]> wrote

> "Johan Nilsson" <r.johan.nilsson_at_[hidden]> writes:
>
>> Hi,
>>
>> I guess that the subject line isn't even technically correct. What I'd
>> like
>> to do is to implement something like the following:
>>
>> #define FOO(x) MyNamedParamFn(x, d = 3, e = 4)
>>
>> Where e.g.
>>
>> "FOO((a = 0, b = 1));"
>>
>> would expand to the equivalent of:
>>
>> MyNamedParamFn(a = 0, b= 1, d = 3, e = 4);
>>
>> Is this possible?
>
> Not with a C++03 preprocessor, because there's no way to "peel apart"
> a comma-separated list like (a = 0, b = 1) without knowing how many
> elements are in it. With a C99/C++0x preprocessor, you could do it.

What is possible, though, is something like:

FOO_2(a = 0, b = 1)

or

FOO((a = 0)(b = 1))

Regards,
Arkadiy


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