views:

45

answers:

1

Hello, I have some templated function which has different number of arguments due to the template-type. This function is wrapped with macro definition.

#define SomeTemplate(TemplateType, Arguments) someFunc<TemplateType>(Arguments);

Everything is okay until I'm using only 1 argument for function calling. But I need in more. I looked at boost it does such things through definition of different macros, like:

#define TEMP_1(Arg1) someFunc<Template>(Arg1);
#define TEMP_2(Arg1, Arg2) someFunc<Template>(Arg1, Arg2);
#define TEMP_3(Arg1, Arg2, Arg3) someFunc<Template>(Arg1, Arg2, Arg3);

But this code marked as portable for compilres. There is way to use some defines with any number of arguments. How can I do that?

+2  A: 

the only way to do that us using __VA__ARGS__ in the macro definations, however, its not as portable, beacuse older compilers like VC6 doesn't support var arg'ed macros, see: MSVC GCC

Necrolis
I wouldn't worry about VC6: it doesn't support C++.
Mike Seymour
it supports C++ alright (I use it for legacy development), you just can't get too carried away with templates and macros, plus you need so use a better STL, VC6's one (as a friend describes it) is AIDS
Necrolis