I would like to implement a template class, with specializations for std::is_arithmetic types, as well as other specific vector classes, such as :
struct Vector { double x = 0; double y = 0; double z = 0; };
I have tried:
template<typename T, typename std::enable_if_t<std::is_arithmetic_v<T>>>
class arith { static constexpr const T zero() { return (T)0; } };
template<typename T, typename std::enable_if_t<std::is_same_v<typename T, Vector>>>
class arith { static inline Vector zero() { return Vector(); } };
This causes a "template parameter '__formal' is incompatible with the declaration, on second template
I have tried with a generic empty class, that would be specialized:
template<typename T, typename Enable = void>
class arith { };
template<typename T, typename std::enable_if_t<std::is_arithmetic_v<T>>>
class arith { static constexpr const T zero() { return (T)0; } };
template<typename T, typename std::enable_if_t<std::is_same_v<typename T, Vector>>>
class arith { static inline Vector zero() { return Vector(); } };
But in that case, both specialization fail to compile with "template parameter 'Enable' is incompatible with declaration"
I also tried full specialization for Vector class, and various other solutions ... without success. I can do it via full specialization for every type, but can't get the std::is_arithmetic version to work.