Implement std::hash for boost::fibers::context::id

This commit is contained in:
Danil Sidoruk
2024-09-12 21:09:41 +03:00
parent 7838ab09d7
commit 4eb7c3210f
2 changed files with 22 additions and 0 deletions
+12
View File
@@ -174,6 +174,7 @@ private:
public:
class id {
private:
friend std::hash<id>;
context * impl_{ nullptr };
public:
@@ -520,6 +521,17 @@ static intrusive_ptr< context > make_worker_context( launch policy,
}}
// std::hash specialization
namespace std {
template <>
struct hash< ::boost::fibers::context::id > {
std::size_t
operator() ( ::boost::fibers::context::id const& id ) const noexcept;
};
}
#ifdef _MSC_VER
# pragma warning(pop)
#endif
+10
View File
@@ -434,6 +434,16 @@ context::attach( context * ctx) noexcept {
}}
namespace std {
std::size_t
hash< ::boost::fibers::context::id >::operator() ( ::boost::fibers::context::id const& id ) const noexcept {
return reinterpret_cast<std::size_t>(id.impl_);
}
}
#ifdef BOOST_HAS_ABI_HEADERS
# include BOOST_ABI_SUFFIX
#endif