The best I came up with so far is the following, which requires at least a typedef with a common name in all the specialization of hash:
template struct hash;
template <> struct hash {
typedef int value_type;
};
template
constexpr bool is_defined_hash_type(typename hash::value_type) {
return true;
}
template
constexpr bool is_defined_hash_type(T) {
return false;
}
int main()
{
static_assert ( is_defined_hash_type< int >(0), "hash should be defined");
static_assert (! is_defined_hash_type< double>(0), "hash should not be defined");
return 0;
}
The syntax is pretty ugly, due to the added parameter (needed to trigger SFINAE). If you think it may be the way to go, I'll try to clean it up further.
Disclaimer: I am by no means a C++11 expert, so I may have missed some points using new features. In that case fire at will and I'll try to correct the answer.