Why doesn't this C++11 program work:
template <typename T>
void f(T t = 42) {}
int main() { f(); }
Why can't T
be deduced from the default argument 42
?
Why doesn't this C++11 program work:
template <typename T>
void f(T t = 42) {}
int main() { f(); }
Why can't T
be deduced from the default argument 42
?
14.8.2.5 [temp.deduct.type]:
19 - A template type-parameter cannot be deduced from the type of a function default argument. [...]
The example given is substantially the same as yours.