I will put a mail copy of a possible DR that I recently posted on Christmas here
Is the following code formed correctly?
template<typename T> struct A { A<T>(); };
Several compilers I tested (clang, g ++ and conau conline) Accept this. Indeed, 12.1 does not prohibit this ( A<T> is the name of this class and is not typedef-name), but 8.3p1 says
The unqualified identifier found in the declarator identifier should be a simple identifier, with the exception of the declaration of some special functions (12.3, 12.4, 13.5) ...
The constructor is a special member function, but the list of crosses doesnโt include 12.1. Does this mean that the above code is poorly formed? Or is this an accidental omission?
If you do the same in the out of turn definition, you will try to pass the template arguments to the constructor. This is a valid code.
struct A { template<typename T> A(); }; template<> A::A<int>() { }
The specification states that when the name of the entered class is used in the qualified name when searching in the class of the class (as in A::A ), then when the name search accepts the names of functions / constructors, a reference to the name of the entered class will be translated to be resolved to the constructor (s) of this class (if the name search context accepts only types, the name will remain the name of the entered class and will indicate the type of class). After A::A name search is complete and gives a constructor. Then <int> can only be parsed as a list of template arguments. If there is no template among your constructors, your code will be invalid.
source share