I’m attempting to have a derived class (normal template) that has a variable of a template type that has as its template class parameter the type of a base class (normal template, same parameter as the derived class) of the derived class (the one with the variable). This makes VC++ incredibly angry at me, and I am incapable of calming its fury. Here’s a quick example:
template<template<typename VT> class CT, typename VT> struct encapThing {};
template<typename VT> struct innocuousBase {};
template<typename VT> struct derivOfDoom : public innocuousBase<VT>
{
encapThing<innocuousBase, VT> ohgodhelp; //C3200
};
It will throw a C3200, saying it expected a class template. Now, I can see why this might be thinking there is a recursive loop of templates within templates, even if this isn’t actually the case. How can I convince VC++ otherwise?
Unqualified use of
innocuousBaseinside ofderivOfDoom<>is interpreted asinnocuousBase<VT>, much as unqualified use ofderivOfDoomin that context would be interpreted asderivOfDoom<VT>. I don’t remember offhand whether or not this is standard-conformant behavior, but the workaround is trivial: fully qualifyinnocuousBaseso the compiler knows you’re referring to theinnocuousBaseclass template and not theinnocuousBase<VT>base class: