diff --git a/include/boost/container_hash/hash.hpp b/include/boost/container_hash/hash.hpp index b4066b1..1e415a4 100644 --- a/include/boost/container_hash/hash.hpp +++ b/include/boost/container_hash/hash.hpp @@ -26,7 +26,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -38,6 +40,10 @@ #include #include +#if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS) +# include +#endif + #if !defined(BOOST_NO_CXX11_SMART_PTR) # include #endif @@ -163,7 +169,17 @@ namespace boost typename boost::enable_if_::value, std::size_t>::type hash_value( T v ) { - return static_cast( v ); +#if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS) + + typedef typename std::underlying_type::type U; + +#else + + typedef typename boost::conditional< boost::is_signed::value, boost::make_signed, boost::make_unsigned >::type::type U; + +#endif + + return boost::hash_value( static_cast( v ) ); } // floating point types