Creatively apply patch from #2603. Refs #2603.

[SVN r76111]
This commit is contained in:
Peter Dimov committed 2011-12-23 03:00:05 +00:00
1 parent 017ab7e2ee
commit 57a5441ebf
5 files changed
+139 -4

No files matched your search

+57
View File
@@ -0,0 +1,57 @@
#ifndef BOOST_SMART_PTR_OWNER_LESS_HPP_INCLUDED
#define BOOST_SMART_PTR_OWNER_LESS_HPP_INCLUDED
//
// owner_less.hpp
//
// Copyright (c) 2008 Frank Mori Hess
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// See http://www.boost.org/libs/smart_ptr/smart_ptr.htm for documentation.
//
#include <functional>
namespace boost
{
template<typename T> class shared_ptr;
template<typename T> class weak_ptr;
namespace detail
{
template<typename T, typename U>
struct generic_owner_less : public std::binary_function<T, T, bool>
{
bool operator()(const T &lhs, const T &rhs) const
{
return lhs.owner_before(rhs);
}
bool operator()(const T &lhs, const U &rhs) const
{
return lhs.owner_before(rhs);
}
bool operator()(const U &lhs, const T &rhs) const
{
return lhs.owner_before(rhs);
}
};
} // namespace detail
template<typename T> struct owner_less;
template<typename T>
struct owner_less<shared_ptr<T> >:
public detail::generic_owner_less<shared_ptr<T>, weak_ptr<T> >
{};
template<typename T>
struct owner_less<weak_ptr<T> >:
public detail::generic_owner_less<weak_ptr<T>, shared_ptr<T> >
{};
} // namespace boost
#endif // #ifndef BOOST_SMART_PTR_OWNER_LESS_HPP_INCLUDED
+7 -2
View File
@@ -443,7 +443,12 @@ public:
pn.swap(other.pn);
}
template<class Y> bool _internal_less(shared_ptr<Y> const & rhs) const
template<class Y> bool owner_before( shared_ptr<Y> const & rhs ) const
{
return pn < rhs.pn;
}
template<class Y> bool owner_before( weak_ptr<Y> const & rhs ) const
{
return pn < rhs.pn;
}
@@ -499,7 +504,7 @@ template<class T> inline bool operator!=(shared_ptr<T> const & a, shared_ptr<T>
template<class T, class U> inline bool operator<(shared_ptr<T> const & a, shared_ptr<U> const & b)
{
return a._internal_less(b);
return a.owner_before( b );
}
template<class T> inline void swap(shared_ptr<T> & a, shared_ptr<T> & b)
+7 -2
View File
@@ -206,7 +206,12 @@ public:
pn = r.pn;
}
template<class Y> bool _internal_less(weak_ptr<Y> const & rhs) const
template<class Y> bool owner_before( weak_ptr<Y> const & rhs ) const
{
return pn < rhs.pn;
}
template<class Y> bool owner_before( shared_ptr<Y> const & rhs ) const
{
return pn < rhs.pn;
}
@@ -230,7 +235,7 @@ private:
template<class T, class U> inline bool operator<(weak_ptr<T> const & a, weak_ptr<U> const & b)
{
return a._internal_less(b);
return a.owner_before( b );
}
template<class T> void swap(weak_ptr<T> & a, weak_ptr<T> & b)