In N3126 ( Warning: very large PDF ) 14.1 / 9, there are two statements that make me confused:
#1: "The default template argument may be specified in the template declaration."
#2: "The default argument template should not be specified in the parameter list of the template definition for the member of the class template that appears outside the class of participants."
#1 means the following code is legal:
template <class T = int> void f(T = T()) {} int main() { int n = f();
#2 means the following code is illegal:
template <class T> struct X { template <class U = T> void f(U a = U()) {} }; int main() { X<int> x; xf();
I'm just wondering why the latter should be explicitly defined as illegal by the standard?
What is the rationale?
source share