Ticket #2603: owner_before.patch

File owner_before.patch, 2.2 KB (added by Frank Mori Hess, 14 years ago)

patch which adds owner_before members to shared_ptr and weak_ptr

  • boost/shared_ptr.hpp

     
    511511        return pn;
    512512    }
    513513
    514     template<class Y> bool _internal_less(shared_ptr<Y> const & rhs) const
     514    template<class Y> bool owner_before(shared_ptr<Y> const & rhs) const
    515515    {
    516516        return pn < rhs.pn;
    517517    }
    518518
     519    template<class Y> bool owner_before(weak_ptr<Y> const & rhs) const
     520    {
     521        return pn < rhs.pn;
     522    }
     523
    519524    bool _internal_equiv( shared_ptr const & r ) const
    520525    {
    521526        return px == r.px && pn == r.pn;
     
    562567
    563568template<class T, class U> inline bool operator<(shared_ptr<T> const & a, shared_ptr<U> const & b)
    564569{
    565     return a._internal_less(b);
     570    return a.owner_before(b);
    566571}
    567572
    568573template<class T> inline void swap(shared_ptr<T> & a, shared_ptr<T> & b)
  • boost/weak_ptr.hpp

     
    141141        pn = pn2;
    142142    }
    143143
    144     template<class Y> bool _internal_less(weak_ptr<Y> const & rhs) const
     144    template<class Y> bool owner_before(shared_ptr<Y> const & rhs) const
    145145    {
    146146        return pn < rhs.pn;
    147147    }
    148148
     149    template<class Y> bool owner_before(weak_ptr<Y> const & rhs) const
     150    {
     151        return pn < rhs.pn;
     152    }
     153
    149154// Tasteless as this may seem, making all members public allows member templates
    150155// to work in the absence of member template friends. (Matthew Langston)
    151156
     
    165170
    166171template<class T, class U> inline bool operator<(weak_ptr<T> const & a, weak_ptr<U> const & b)
    167172{
    168     return a._internal_less(b);
     173    return a.owner_before(b);
    169174}
    170175
    171176template<class T> void swap(weak_ptr<T> & a, weak_ptr<T> & b)
  • libs/smart_ptr/test/Jamfile.v2

     
    5050          [ run wp_convertible_test.cpp ]
    5151          [ run ip_convertible_test.cpp ]
    5252          [ run allocate_shared_test.cpp ]
     53          [ run owner_less_test.cpp ]
    5354        ;
    5455}