Disagreement over the use of type aliases in nested classes

clang ++ and g ++ do not agree with the validity of the following code:

template<typename T>
struct thing {
    struct nested {
        typename thing::type num;
    };
    using type = int;
};

All versions of g ++ (4.8 and higher) will compile this without problems, all versions of clang (3.0 and higher) complain about those thing::typethat are not defined.

Obviously, if thingthey were not a template, no compiler would agree with this, but who is right here and why?

Thanks in advance.

+4
source share

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


All Articles