From e9cdb10409e69706863472c5b4c33749cb9b3a1e Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Mon, 14 Jun 2021 01:51:33 +0300 Subject: [PATCH] Use std::hash in hash_value --- include/boost/system/detail/error_code.hpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/include/boost/system/detail/error_code.hpp b/include/boost/system/detail/error_code.hpp index af83e37..8d3df1b 100644 --- a/include/boost/system/detail/error_code.hpp +++ b/include/boost/system/detail/error_code.hpp @@ -44,8 +44,14 @@ namespace system // and error_code containing a pointer to an object of a type derived // from error_category. +std::size_t hash_value( error_code const & ec ); + class error_code { +private: + + friend std::size_t hash_value( error_code const & ec ); + private: struct data @@ -352,6 +358,16 @@ public: inline std::size_t hash_value( error_code const & ec ) { +#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR) + + if( ec.flags_ == 1 ) + { + std::error_code const& e2 = *reinterpret_cast( ec.d2_ ); + return std::hash()( e2 ); + } + +#endif + error_category const & cat = ec.category(); boost::ulong_long_type id_ = cat.id_;