Move std::unique_ptr, std::shared_ptr support into hash.hpp

This commit is contained in:
Peter Dimov
2021-10-17 02:14:19 +03:00
parent 7a29dee42a
commit a63c85007f
2 changed files with 22 additions and 16 deletions

View File

@@ -26,10 +26,6 @@
# include <tuple> # include <tuple>
#endif #endif
#if !defined(BOOST_NO_CXX11_SMART_PTR)
# include <memory>
#endif
namespace boost namespace boost
{ {
#if !defined(BOOST_NO_CXX11_HDR_TUPLE) #if !defined(BOOST_NO_CXX11_HDR_TUPLE)
@@ -134,18 +130,6 @@ namespace boost
#endif #endif
#endif
#if !defined(BOOST_NO_CXX11_SMART_PTR)
template <typename T>
inline std::size_t hash_value(std::shared_ptr<T> const& x) {
return boost::hash_value(x.get());
}
template <typename T, typename Deleter>
inline std::size_t hash_value(std::unique_ptr<T, Deleter> const& x) {
return boost::hash_value(x.get());
}
#endif #endif
// //

View File

@@ -34,6 +34,10 @@
#include <utility> #include <utility>
#include <climits> #include <climits>
#if !defined(BOOST_NO_CXX11_SMART_PTR)
# include <memory>
#endif
#if !defined(BOOST_NO_CXX11_HDR_TYPEINDEX) #if !defined(BOOST_NO_CXX11_HDR_TYPEINDEX)
#include <typeindex> #include <typeindex>
#endif #endif
@@ -244,6 +248,24 @@ namespace boost
return boost::hash_unordered_range( v.begin(), v.end() ); return boost::hash_unordered_range( v.begin(), v.end() );
} }
#endif
// std::unique_ptr, std::shared_ptr
#if !defined(BOOST_NO_CXX11_SMART_PTR)
template <typename T>
std::size_t hash_value( std::shared_ptr<T> const& x )
{
return boost::hash_value( x.get() );
}
template <typename T, typename Deleter>
std::size_t hash_value( std::unique_ptr<T, Deleter> const& x )
{
return boost::hash_value( x.get() );
}
#endif #endif
// std::type_index // std::type_index