On 6/15/07, Server Levent Yilmaz <leventyilmaz@gmail.com> wrote:
Hi,

I have the following fun problem, seemingly simple, but couldn't find the trick.

The objective is to convert a given argument list to some other one or more useful argument list. Each of the arguments are copied verbatim into the other list unless it is specified to be a SPECIAL_TYPE.

For example the following two-argument macro function call:

FUNKY_MACRO( 5, ( double*, SPECIAL_TYPE, const char[], SPECIAL_TYPE, int)  )

would spit out:

(double*, const char[],          int,  special1, special1);
(double*,     special1, const char[],  special1,      int, special2, special2);

note that, in the first generated tuple SPECIAL_TYPE is replaced by some other text, and moved to the end of the tuple. In the second one, same replacement occurs and some yet other text is appended repeatedly at the end, same number of times as SPECIAL_TYPE appears in the original list.

Any ideas how to do this (or part of it) with the incredibly amazing Preprocessor library?

thanks

--


I have a related, simpler question:


Given a tuple (or any other container) with arbitrary elements, is there a way to determine if an element is SPECIAL_TEXT or some other text.  For example given, ( a, b, SPECIAL_TEXT, c, d ), can we construct (0, 0, 1, 0, 0)?



Levent