This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Referring to a base class with template template parameters
- From: Ian Lance Taylor <iant at google dot com>
- To: Deth <alexrepair at gmail dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Sat, 07 Nov 2009 23:19:49 -0800
- Subject: Re: Referring to a base class with template template parameters
- References: <26249699.post@talk.nabble.com>
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