Date: Sun, 8 Jan 2023 12:41:49 -0500
According to 9.3.4.7 [dcl.fct.default] paragraph 6,
Default arguments for a member function of a class template shall be
specified on the initial declaration of the member function within
the class template.
This wording does not include redeclarations of member functions of
classes nested within class templates, so it implies that the
following program is well-formed:
template<class> struct A { struct B { void c(int); }; };
template<class T> void A<T>::B::c(int = 0) {}
int main() {}
However, only MSVC accepts this program; both GCC and Clang reject it.
Is it intentional that such declarations are valid?
Default arguments for a member function of a class template shall be
specified on the initial declaration of the member function within
the class template.
This wording does not include redeclarations of member functions of
classes nested within class templates, so it implies that the
following program is well-formed:
template<class> struct A { struct B { void c(int); }; };
template<class T> void A<T>::B::c(int = 0) {}
int main() {}
However, only MSVC accepts this program; both GCC and Clang reject it.
Is it intentional that such declarations are valid?
Received on 2023-01-08 17:42:01