Personal friendship pattern

template < typename T > struct test { template < typename U > friend struct test<U>; }; int main() {} 

This is absolutely correct code, no? I ask because MSVC ++ 2010 cannot compile it. However, this is not the first time that the templates have confused the MS compiler. As far as I can judge by books, sites, etc., It should work.

+2
source share
1 answer

The correct syntax is:

 template < typename T > struct test { template < typename U > friend struct test; // no <U> }; int main() {} 
+3
source

Source: https://habr.com/ru/post/973489/


All Articles