Re: MoreCRTP question
* kostas:
Hi all
I encountered a problem testing a variation of CRTP.
(It's also proposed in "C++ Templates: The Complete Guide" by
Vandevoorde, Josuttis. See the MoreCurious template class in 16.3)
template<class T, template <typename> class D>
class Base
{
protected:
Base(T x): i(x) {}
T i;
};
template<class T>
class Derived:public Base<T, Derived>
{
Derived(T x):Base<T, Derived>(x){}
};
the problem is that in the Base ctor call (from within Derived ctor)
the Derived parameter is not recognized as class template. Old gcc
versions(3.3.3) could cope with this, but not any more. Other
compilers have also problem.
So is it a language or a compiler issue?
Do you know some workaround?
Any help is appreciated.
I failed to find anything about it in the standard, but adding the magic
word "class" before "Derived" seems to do the trick.
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?