boost policy against inline friend functions?

I've noticed boost::shared_ptr and other classes avoid using inline friend functions, e.g. operator < in class shared_ptr scope: public: template<class Y> bool _internal_less(shared_ptr<Y> const & rhs) const { return pn < rhs.pn; } in namespace scope: template<class T, class U> inline bool operator<(shared_ptr<T> const & a, shared_ptr<U> const & b) { return a._internal_less(b); } what's wrong with template<class Y> friend bool operator<(shared_ptr<Y> const & rhs) const { return pn < rhs.pn; } in class shared_ptr? compiler compatibility? other reasons? should boost libraries avoid inline friend functions in general?

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Monday 26 October 2009, Stefan Strasser wrote:
Apparently some compilers don't support template friends. There is the BOOST_NO_MEMBER_TEMPLATE_FRIENDS config macro to detect this though. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEARECAAYFAkrl/PsACgkQ5vihyNWuA4URYgCfb2IcHoiFJAFwuivQnR89JfTH Ty8AnijmNMSSB9tmHpR5M95kBSD6TDs/ =MwTI -----END PGP SIGNATURE-----

Apparently some compilers don't support template friends. There is the BOOST_NO_MEMBER_TEMPLATE_FRIENDS config macro to detect this though.
There's also a comment below the public comparison functions: // Tasteless as this may seem, making all members public allows member templates // to work in the absence of member template friends. (Matthew Langston) Philippe

Am Monday 26 October 2009 20:50:45 schrieb Philippe Vaucher:
thanks, I missed that. I checked the conditions for NO_MEMBER_TEMPLATE_FRIENDS and all current compilers seem to support it. so I guess there is no reason not to use member template friends in new (proposed) boost libraries, unless you intend to make it uber-portable.

On Mon, Oct 26, 2009 at 3:13 PM, Beman Dawes <bdawes@acm.org> wrote:
I suspect that some users still use VC++ 6. Otherwise, perhaps we should remove all such workarounds, including macros like NO_MEMBER_TEMPLATE_FRIENDS? Though I know that there is still some disagreements between different compilers about what (instance of a) function template is friend to what type. :) Emil Dotchevski Reverge Studios, Inc. http://www.revergestudios.com/reblog/index.php?n=ReCode
participants (5)
-
Beman Dawes
-
Emil Dotchevski
-
Frank Mori Hess
-
Philippe Vaucher
-
Stefan Strasser