This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Referring to a base class with template template parameters


Deth <alexrepair@gmail.com> writes:

> I'm having issues referring to a base class under specific circumstances, and
> am hoping that someone can provide a work-around.
>
> I have a base class A with a template template parameter T:
>
> template <template <typename> class T>
> class A {
> public:
>    A(int) {}
> };
>
> I then have a templated child class that derives from A using CRTP:
>
> template <typename>
> class B : public A {
> public:
>    B(int i)
>       : A(i) {}
> };
>
> gcc reports the following error on the line with B's constructor initializer
> list:
> "error: expected a class template, got 'B< <template-parameter-1-1> >
>
> I can accomplish this in Visual Studio, but I can't find the syntax to make
> it work in gcc v4.2.1



I don't know why your code would work in Visual Studio.  To me it
looks wrong in several places.

This code works in gcc, and I believe is standard conformant.


template <typename T>
class A {
public:
   A(int) {}
};

template <typename T>
class B : public A<B<T> > {
public:
   B(int i)
     : A<B<T> >(i) {}
};


Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]