EDIT: I took the \"if/else\" case as an example that can sometimes be resolved at compile time (eg when static values are involved, cf
The compiler may be smart enough to see that it can replace the On second thought, if
statement body with two different function implementations, and just choose the right one. But as of 2014 I doubt there is any compiler that is smart enough to do that. I may be wrong though.std::is_integral
is simple enough that I think it will be optimized away.
Your idea of overloading on the result of std::is_integral
is one possible solution.
Another and IMHO cleaner solution is to use std::enable_if
(together with std::is_integral
).