Suppose I have a simple class types boolean, MyTrait. That is, for any type, TI can do MyTrait<T>::valueand get either true or false. I would like to specialize std::hashfor all types Twhere MyTrait<T>::valueis true. Is there any way to do this? Some unsuccessful attempts:
template <class T, typename std::enable_if<
MyTrait<T>::value, int
>::type = 0>
struct hash<T> {
...
}
Failure because:
error: default template argument in a class template partial specialization
I also tried to put all of the partial specialization properties after the hash, but then an error message appears for Tbeing in an undetectable context.
Is there any way to do this? At least one previous question about SO does not offer: The specialization of std :: hash for derived classes .
, "", , .