Is there a subtle trick for template specialization so that I can apply one specialization to basic POD (when I say basic POD, I don't really want a struct POD (but I will take that)).
template<typename T> struct DoStuff { void operator()() { std::cout << "Generic\n";} }; template<> struct DoStuff</*SOme Magic*/> { void operator()() { std::cout << "POD Type\n";} };
Or do I need to write specializations for each of the built-in types?
template<typename T> struct DoStuff { void operator()() { std::cout << "Generic\n";} }; // Repeat the following template for each of // unsigned long long, unsigned long, unsigned int, unsigned short, unsigned char // long long, long, int, short, signed char // long double, double, float, bool // Did I forget anything? // // Is char covered by unsigned/signed char or do I need a specialization for that? template<> struct DoStuff<int> { void operator()() { std::cout << "POD Type\n";} };
Unit Test.
int main() { DoStuff<int> intStuff; intStuff();
source share