Default template parameter redeclaration
[temp.param]/12 Clearly states :
A template-parameter shall not be given default arguments by two different declarations in the same scope.
now, both clang and g++ generates errors for following code:
template<class T = int> class X; template<class T = int> class X {};
msvc on the other hand (even with no extensions enabled) compiles it fine, I had to change second default parameter from int to some other type to see error. So its not that really bad, but still ‘shall not’ means ‘is not allowed’ as per ISO/IEC Directives. msvc on the other hand gives error in similar case but with redeclaration of function default parameter values.
Leave a Reply