How to stringize a string with comma in it?

#define CSTR1(a) #a
#define CSTR(a) CSTR1(a)

#define CLASSNAME_TEMPLATED(className, param1, param2) \
className<param1, param2>

int main()
{
cout << CSTR(CLASSNAME_TEMPLATED(map, int, int)) << endl;
return 0;
}

Now I have such a problem:
I need full name of a class (with template params), to automatically create classes
But if there are 2 or more than 2 params in template list, G++ will split the string because there are comma(s) in it, while VS2008 not
I know this may be undefined behavior
But is there any method to get full class name?
Use an extra set of parens:

 
CSTR((CLASSNAME_TEMPLATED(map, int, int)))


The evils of macros.
Topic archived. No new replies allowed.