Template name disambiguation: g++ vs clang++

151 views Asked by At

Premise: g++ and clang++ are known to be sometime discordant or not compliant on applying the rules for template disambiguation for dependent names.

In this regard, the following code compiles under g++ but does not under clang++:

template<class T1>
struct A {
    template <class T2>
    class Anested {
        public:
        typedef A<T2> Other;
    };
};

template <class T>
struct B {
    typedef B<T> Myself;
    typedef typename T::Anested<Myself>::Other Other; //clang++ requires "template" before "Anested" to compile
};

int main() {
    B<A<void>> b;
}

clang++ is compliant in this case (isn't it?), but I am wondering whether the "template" keyword is actually redundant in this kind of statement. If it is not redundant, could you please make some examples to prove that the deduction rule followed by g++ is flawed?

0

There are 0 answers