Could that code to be compile?
#include <iostream>
template <typename T>
struct TMPL
{
using TP = typename T::TP; //is CL::TP visible (with T == CL)?
};
struct CL
{
using TP = int;
TMPL<CL>::TP val;
};
int main()
{
CL cl;
}
TMPL is instantiated immediately before CL class definition according to Standard 14.6.4.1/4
For a class template specialization, ..., if the specialization is implicitly instantiated because it is referenced from within another template specialization, .... Otherwise, the point of instantiation for such a specialization immediately precedes the namespace scope declaration or definition that refers to the specialization.
So, CL::TP isn't visible in TMPL instantiation point, but all the compilers (MSVC, gcc, clang) compile it fine. I also has found a defect report http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#287, but it, apparently, wasn't accepted
Your example is not identical to the one in the defect report. In the defect report,
CL
is a class template. However the intent of the proposed resolution is to make the template case the same as the non-template one, aka [basic.scope.pdecl]:Then the proposed resolution:
As of the latest draft, the non-template case was and is still valid. The template case is not. However the defect is drafting, which means that the template case is intended to compile.