As an exercise I was trying to see if I could use SFINAE to create a std::hash
specialization for std::pair
and std::tuple
when all of
You are not supposed to specialize std::hash
for types that doesn't depend on a type you defined yourself.
That said, this hack might work:
template<class T, class E>
using first = T;
template <typename T>
struct hash<first<std::pair<T, T>, std::enable_if_t<std::is_unsigned<T>::value>>>
{
size_t operator()(const std::pair<T, T>& x) const
{
return x;
}
};
Really, though, don't do this. Write your own hasher.