This is sort of a long shot since I'm not terribly experienced with templates, but...
Code:
#include <string>
#include <map>
#include <iostream>
template <typename T>
void myFunction()
{
T var;
//do something
}
int main()
{
std::map<std::string, void (*)()> funcMap;
funcMap["unsigned char"] = myFunction<unsigned char>;
funcMap["unsigned short"] = myFunction<unsigned short>;
funcMap["unsigned int"] = myFunction<unsigned int>;
funcMap["unsigned long"] = myFunction<unsigned long>;
funcMap["long double"] = myFunction<long double>;
funcMap["char"] = myFunction<char>;
//etc.
std::string type;
std::getline(std::cin, type);
funcMap[type]();
return 0;
}
As I said, not totally sure if that'll compile or run properly, and it's a cheat anyway.