C++ convert string to typename
C++ convert string to typename So I've found a variety of articles and posts saying that there is no way to convert typename to string but I haven't found one about the opposite. I have a template of a function with specializations: typename string template template <typename T> void foo(T sth) {} template <> void foo<int>(int sth) {} ... and I'm reading from a file constructed like this: int 20 double 12.492 string word Is there a way to call the correct specialization of foo() depending on the content of the file? foo() Templates are compile-time constructs, you cannot instantiate or choose template specializations at runtime – UnholySheep Jul 1 at 21:11 if (std::compare(sType)=="string" {...} else if (std::compare(sType)=="int") {......