Re: Referring to a base class with template template parameters

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Deth <alexrepair@xxxxxxxxx> 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 of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux