0

Let's say I have a simple template class like this:

template<class x> class TParent 
{
public: 
    int Variable;
};

template<class x> class TChild : public TParent<x>
{
    typedef TParent<x> SUPER;
public:
    void Method() { Variable = 1; };   // *ERROR* needs to be SUPER::Variable = 1;
};

It works fine with Microsoft compiler, but LLVM & Clang don't like it and need the mentioned change. But it has no sense and it all works fine if the classes are not templates. Is there a way to disable this riddiculous error?

Of course it's very easy to fix that and for smaller classes it is acceptable, but if the template is a huge class consisting of thousands of lines, accessing members from the parent all the time, it makes the code very ugly and hard to read.

mrzacek mrzacek
  • 308
  • 2
  • 12
  • 1
    Are you sure that this is an error in LLVM/clang and not just VS being not as strict? – EdChum Jan 09 '15 at 13:20
  • Clang and gcc are right here. See link posted above. There's a tip about using `using`. – oblitum Jan 09 '15 at 13:27
  • Just one thing: a huge class consisting of thousands of lines is in itself a possible maintenance nightmare and especially with multiple inheritance, it may be even worthwhile to know where the variable is actually declared (also possibly resolving name clashes). – stefaanv Jan 09 '15 at 13:34
  • Ok, so "using" helps, but using it on all members is just crazy. I want the templates to work like classes, which they are, but just don't work in GCC & CLANG. For some reason Microsoft compiler works fine and Intel as well, so I'd guess it's just some archaic convention, which makes it easier to develop a compiler, but it's just horrible... – mrzacek mrzacek Jan 19 '15 at 14:46

0 Answers0