views:

50

answers:

0
template < typename T >
struct test
{
  template < typename U >
  friend struct test<U>;
};

int main() {}

This is perfectly valid code, no? I ask because MSVC++ 2010 fails to compile it. Not the first time templates have confuzled the MS compiler though. As far as I can tell from books, websites, and such it should work.

The correct syntax is:

template < typename T >
struct test
{
  template < typename U >
  friend struct test; // no <U>
};

int main() {}