Consider:
void f() { return 5; }
The above will cause errors. But why not this ?:
template <typename = void> void f() { return 0; }
I am compiling gcc-4.5.1. Why does it matter using templates so that I don't get errors from executing the same illegal return statement as a function without a template ?. The only thing I get is that I cannot call the function (ie f() ) without getting:
error: return-statement with a value, in function returning 'void'
But still, what could be the reason that I can define a return statement for the void function template?
Here is the code I have:
template <typename = void> void f() { return 0; }
The above code will pass despite the supposedly illegal return statement in the function returning void.
source share