Problem with forward declaration of classes with nested templates

Steven Keuchel steven.keuchel@gmail.com
Mon Sep 25 23:07:00 GMT 2006


Hi John,

oh, thanks i thought i simplified as much as i can. But i guess i was
wrong. Maybe i shouldn't simplify that much. My the real problem
occurs when using 2 recurring templates like this:

-----------------
struct a;
struct b;

struct a
{
    template<int i>
    struct impl : public b::template impl<i>
    {};
};

struct b
{
    template<int i>
    struct impl : public a::template impl<i-1>
    {};
};
-----------------

but I know i can be happy by rewriting it to:

-----------------
struct a;
struct b;

struct a
{
    template<int i>
    struct impl;
};

struct b
{
    template<int i>
    struct impl;
};

template<int i>
struct a::impl : public b::template impl<i>
{};

template<int i>
struct b::impl : public a::template impl<i-1>
{};
-----------------

But the question still remains, why doesn't it compile. Can you name something ?

Regards,
  Steven

On 9/26/06, John (Eljay) Love-Jensen <eljay@adobe.com> wrote:
> Hi Steven,
>
> It does not compile for the same reason this does not compile:
>
> -----------------
> struct b;
>
> struct a : public b
> {};
>
> struct b
> {};
> -----------------
>
> HTH,
> --Eljay
>



More information about the Gcc-help mailing list