make hash_value work on expired torrent_handles

This commit is contained in:
Arvid Norberg 2012-11-10 19:50:10 +00:00
parent 85cda6cf53
commit 816f405a15
1 changed files with 3 additions and 1 deletions

View File

@ -988,7 +988,9 @@ namespace libtorrent
std::size_t hash_value(torrent_handle const& th)
{
return std::size_t(th.m_torrent.lock().get());
// using the locked shared_ptr value as hash doesn't work
// for expired weak_ptrs. So, we're left with a hack
return std::size_t(*reinterpret_cast<void* const*>(&th.m_torrent));
}
}