R S*_*R S 6 c++ hash boost unordered-map bitset
I want to use a cache, implemented by boost's unordered_map, from a dynamic_bitset to a dynamic_bitset. The problem, of course, is that there is no default hash function from the bitset. It doesn't seem to be like a conceptual problem, but I don't know how to work out the technicalities. How should I do that?
我发现了一个意想不到的解 事实证明,助推有一个选择#define BOOST_DYNAMIC_BITSET_DONT_USE_FRIENDS.当这个被定义时,包括m_bits公开的私人成员(我认为它可以处理旧的编译器或其他东西).
所以现在我可以使用@ KennyTM的答案,改了一下:
namespace boost {
template <typename B, typename A>
std::size_t hash_value(const boost::dynamic_bitset<B, A>& bs) {
return boost::hash_value(bs.m_bits);
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1998 次 |
| 最近记录: |