C ++ dependent name: is this name required?

In a.hpp I defined:

 #include <utility> namespace Board { template<int W, int H> struct GroupNode { using PointType = std::pair<int, int>; // ... }; } 

Then in b.cpp I defined:

 #include "a.hpp" namespace Board { template<int W, int H> struct NodeList { using StdList = std::list < /* typename */ GroupNode<W, H>>; } } // and then use NodeList<19, 19> nl; 

The code above can be compiled on both gcc-6 and clang-3.9 without warning. However, Clion 2016.3 complained cannot resolve variable GroupNode to b.cpp . Uncommenting typename might tame Clion's warning, but I was wondering if typename is required? If so, why didn't g ++ / clang ++ give any warnings?

+5
source share
1 answer

No, this is not required. According to [temp.res] / 3 in C ++ 14:

When a qualified identifier is intended to refer to a type that is not a member of the current instance (14.6.2.1) and its nested qualifier refers to a dependent type, it must have a prefix with the typename keyword, forming a typename-specifier. If the identifier with the identifier in the typename-specifier does not indicate the type, the program is inactive, it is formed.

There is no nested qualifier referring to the dependent type, so typename not required. (the nested qualifier refers to :: and the type or namespace on the left. Obviously, std not a type, much less dependent.)

+5
source

Source: https://habr.com/ru/post/1260188/