SFINAE only works for substituted template parameters, not any complication error (or it would be called CEINAE); therefore hash<T> for enums will fail to compile, given a non-enum, rather than being ignored. It's not possible to specialize hash<> for enums, since the primary template does not have en extra Enable template argument for use with enable_if. We therefore rename it to enum_hash<> and require users to explicitly define hash<MyEnum> as inheriting from it.
1.3 KiB
1.3 KiB