Hello, I have some template function and I want to call it using define in c++:
#define CONFIG(key, type, def) getValue<type>(key, def);
Of course, it won't work. Could I make something like this?
Hello, I have some template function and I want to call it using define in c++:
#define CONFIG(key, type, def) getValue<type>(key, def);
Of course, it won't work. Could I make something like this?
It works fine:
template<typename T>
T getValue( int, int ) { return T(); }
#define CONFIG(key, type, def) getValue<type>(key, def);
int main()
{
CONFIG(1, int, 2);
return 0;
}
Why not just write it out? If you truly don't want to have to type a bazillion (is that a number? I forget) you can write a script to handle it for you.
def makeGetValue( _return, _1, _2 ):
print _return + " getValue( int " + _1 + ", int " + _2 + ");"
Or something similar.