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() {}
精彩评论