开发者

template self friendship

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 s开发者_高级运维uch it should work.


The correct syntax is:

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

int main() {}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜