I have the following template function:
template<typename T> std::vector<T> foo::bar(std::vector<T> baz) {
if (!std::numeric_limits<T>::is_integer) {
return baz;
} else {
for(int i = 0; i < baz.size(); ++i) {
baz[i] <<= 1;
}
return baz;
}
If T
is a double
the compiler will complain
'<<' illegal, left operand has type 'double'
Eventhough the shift operation will never be called.
Is there a way to inform the compiler that the shift is never going to be called?