Templates are "decided" during compile time. They cannot be decided dynamically at run-time.
If you want to support certain types (e.g. int
, double
, char
, etc.), you can declare them explicitly in your program and they will be compiled, but only the types you support (or others that you use in your program) will be available for the user to "pick":
template<typename T>
class MyTemplateClass { ... };
class template MyTemplateClass<int>;
class template MyTemplateClass<double>;
class template MyTemplateClass<char>;
int main()
{
// if user wants to create a new int version:
MyTemplate<int> myInt;
// etc ...
return 0;
}