You cannot provide a specialization for just hash::operator()(const T&)
; just specialize the entire struct hash
.
template<typename T>
struct Thing {};
namespace std { namespace tr1 {
template<typename T>
struct hash<Thing<T>>
{
size_t operator()( Thing<T> const& )
{
return 42;
}
};
}}
Another way to do this is to create a hasher for Thing
, and specify this as the second template argument for the unordered_set
.
template<typename T>
struct Thing_hasher
{
size_t operator()( Thing<T>& const )
{
return 42;
}
};
typedef std::unordered_set<Thing<T>, Thing_hasher<T>> things_type;