Using type passed as a template in C++
- by MeDiCS
Is it possible to actually use the type passed as a template for control flow? I'd like to write a function that uses templates, which in turn calls another function based on the type passed:
template <class T> void test_function (T var)
{
//Do stuff
if (T == char) {
bar (var);
} else {
foo (var);
}
//Do even more stuff
}
If not, I'll have to fallback to enums...