forked from boostorg/smart_ptr
Add .owner_hash_value to shared/weak_ptr, hash_value, std::hash/equal_to specializations for weak_ptr
This commit is contained in:
1 parent
bc677e9098
commit
5dd84ea389
8 files changed
+308
-31
No files matched your search
@@ -13,10 +13,11 @@
|
||||
// See http://www.boost.org/libs/smart_ptr/ for documentation.
|
||||
//
|
||||
|
||||
#include <memory> // boost.TR1 include order fix
|
||||
#include <boost/smart_ptr/detail/shared_count.hpp>
|
||||
#include <boost/smart_ptr/shared_ptr.hpp>
|
||||
#include <boost/smart_ptr/detail/sp_noexcept.hpp>
|
||||
#include <memory>
|
||||
#include <cstddef>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
@@ -247,6 +248,11 @@ public:
|
||||
return pn == rhs.pn;
|
||||
}
|
||||
|
||||
std::size_t owner_hash_value() const BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return pn.hash_value();
|
||||
}
|
||||
|
||||
// Tasteless as this may seem, making all members public allows member templates
|
||||
// to work in the absence of member template friends. (Matthew Langston)
|
||||
|
||||
@@ -280,6 +286,40 @@ template<class T> weak_ptr( shared_ptr<T> ) -> weak_ptr<T>;
|
||||
|
||||
#endif
|
||||
|
||||
// hash_value
|
||||
|
||||
template< class T > std::size_t hash_value( boost::weak_ptr<T> const & p ) BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return p.owner_hash_value();
|
||||
}
|
||||
|
||||
} // namespace boost
|
||||
|
||||
// std::hash, std::equal_to
|
||||
|
||||
namespace std
|
||||
{
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_HDR_FUNCTIONAL)
|
||||
|
||||
template<class T> struct hash< ::boost::weak_ptr<T> >
|
||||
{
|
||||
std::size_t operator()( ::boost::weak_ptr<T> const & p ) const BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return p.owner_hash_value();
|
||||
}
|
||||
};
|
||||
|
||||
#endif // #if !defined(BOOST_NO_CXX11_HDR_FUNCTIONAL)
|
||||
|
||||
template<class T> struct equal_to< ::boost::weak_ptr<T> >
|
||||
{
|
||||
bool operator()( ::boost::weak_ptr<T> const & a, ::boost::weak_ptr<T> const & b ) const BOOST_SP_NOEXCEPT
|
||||
{
|
||||
return a.owner_equals( b );
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace std
|
||||
|
||||
#endif // #ifndef BOOST_SMART_PTR_WEAK_PTR_HPP_INCLUDED
|
||||
Reference in new issue
Block a user