Hello all,
for using the unordered_set with a user defined class one can define a custom
hasher. There seems to be the following options:
- overide boost::hash_value
- write ur own custom hash functor
Both options have then an external hash function. I was more thinking about
using a member function as hasher (e.g. like GetHashCode). A supporting class
would be then:
template
struct unary_function_mf : std::unary_function
{
RetType operator()(const T& r) const
{
return (r.*pmf)();
}
};
which makes specifying an unordered_set easier:
boost::unordered_set > uset2;
My questions:
1) is this correct c++
2) does something similar exist in Boost (Boost.Function and Bind doesn't seem
to support his)
3) is there an advantage of using a free function over functor? The free
function has at least one advantage, that it also works with the std::pair
hasher.