0

I am in the following situation:

template<typename T, int N>
class Foo
{
};

// specialization for 0
template<typename T>
class Foo<0>
{
   friend class Foo<T, 1>;
};

That is, I need that Foo<T, 1> is friend of Foo<T, 0>, but I have a compiler error. Is this possible?

Nick
  • 10,309
  • 21
  • 97
  • 201

1 Answers1

7

You have a typo in your specialization:

template<typename T>
class Foo<T, 0>
{     //  ^^^ <= add this
   friend class Foo<T, 1>;
};
Axalo
  • 2,953
  • 4
  • 25
  • 39