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...
Edit: All the answers up to now advise me to use template specialization. I wasn't very specific, but this is the same as not using templates at all because for every different type there's a single, different function call.