template <typename IN,typename OUT,bool isVector>
OUT foo(IN x){
if (isVector){
return x[0];
} else {
return x;
}
}
After asking this question I wrongly assumed, that the above code could compile for e.g.
foo<double,double,false>;
as well as
foo<std::vector<double>,double,true>;
However, even if one of the if-branches never gets executed, it is checked for correctness and thus the above does not compile. How can I fix it?
The code above is a simplified, but I dont know how to fix it, as function templates cannot have partial specialization...