0

I my C++ project I would like to create a new type and automatically create a variable of the type. Suppose we have a 2 typename template struct my_struct

Now I am using

#define FOO(a,b) my_struct<a,b> var_ ## a ## b

which works fine when using POD types or simple structure names, like

FOO(int,double)
FOO(string,double)

But it doesn't work with C++ template types.

FOO(vector<int>,map<int,double>)

Is there any solution for it?

I wouldn't like to require a typedef workaround solution to use the macro

typedef my_vec = vector<int>
ztik
  • 3,482
  • 16
  • 34

0 Answers0