Determining if types alias to the same underlying type in C++
- by emchristiansen
I'd like to write a templated function which changes its behavior depending on template class types passed in. To do this, I'd like to determine the type passed in. For example, something like this:
template <class T>
void foo() {
if (T == int) { // Sadly, this sort of comparison doesn't work
printf("Template parameter was int\n");
} else if (T == char) {
printf("Template parameter was char\n");
}
}
Is this possible?