Boost logo

Boost :

From: Aristid Breitkreuz (aribrei_at_[hidden])
Date: 2006-10-24 17:56:34


Hi,

too funny I recently implemented named parameters for macros, too. But
differently and specialised (no general-purpose framework or anything -
not because it were not doable, but because I didn't need it).

Nevertheless, they are used like this

MACRO((foo, 77) (bar, int))

which will expand to say

MACRO2(int, 77)

The idea is "simple":
1. Generate a valid PP-Sequence from this "tuple-sequence"-thing
2. Generate a set of "modifications" by looking up the value of PARAM_
## param (x), which will expand to (index, x) or something like this.
3. Apply those changes to an initial tuple.
4. Use the tuple to invoke another macro.

I do not know which approach should be considered superior. But I really
consider both interesting. I used my approach in a usable C++ library
already, so the concept (which is the same for both) _is_ practical.

Kind regards,

Aristid

PS: I do not think preprocessor metaprogramming should be over-used but
there are a few places where it fits nicely.

PPS: Quirks!

Am Dienstag, den 24.10.2006, 22:24 +0200 schrieb Tobias Schwinger:
> // ---- client code
>
> MY_MACRO(
> MY_FIRST_ARG(yaba)
> MY_THIRD_ARG(doo)
> MY_SECOND_ARG(daba)
> )
> // expands to: yaba daba doo
>
> MY_MACRO(
> MY_SECOND_ARG(bubu)
> )
> // expands to: 1st_default bubu 3rd_default.
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost


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