MSVC does not implement two-phase name lookup correctly. GCC is correct in reporting this error.
The cause is that names used inside a template which do not depend on the template's parameters are (should be in the case of VC) looked up when the template is defined, not when it's instantiated.
In your case, the compiler has no way of telling that IsNonValid
will come from the base class, so it rightfully complains it doesn't know it. There are two possible solutions:
Qualify the access to
IsNonValid
, so that it's clear to the compiler it (potentially) depends on the template parameters:QString val = this->IsNonValid() ? "Non" : ""; // or QString val = TYPE_LIST::IsNonValid() ? "Non" : "";
Introduce the inherited name into the scope of the derived class:
template <class TYPE_LIST> class Data : public TYPE_LIST { public: using TYPE_LIST::IsNonValid; // the rest as you had it originally
Either of these will make the name dependent and thus postpone its lookup until instnatiation, when the value of TYPE_LIST
is actually known.