mirror of
https://github.com/boostorg/fiber.git
synced 2026-07-21 13:13:32 +00:00
Merge pull request #324 from eoan-ermine/hash
Implement std::hash for boost::fibers::context::id
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user