Reputation: 4650
I want to implement a template method for variable.
But depending on whether the input is a int-variant(char, short, int), I want to handle it somewhat differently from the case when the input is a float-variant (float, double, long double).
Is there a way to do this?
Upvotes: 0
Views: 61
Reputation: 8785
To detect types:
http://en.cppreference.com/w/cpp/types/is_integral
http://en.cppreference.com/w/cpp/types/is_floating_point
Also look into SFINAE and tag dispatch to actually select implementation
Upvotes: 3