Boost logo

Boost :

Subject: [boost] boost policy against inline friend functions?
From: Stefan Strasser (strasser_at_[hidden])
Date: 2009-10-26 16:01:33


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?


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk