I have a class to describe some traits of a type.
template<typename T>
struct my_traits
{
static constexpr int some_trait = 0;
static constexpr T min() { return std::numeric_limtis<T>::min(); }
static constexpr T max() { return std::numeric_limits<T>::max(); }
};
I want to specialize my_traits::some_trait
but when I try:
template<> constexpr int my_traits<int>::some_trait = 1;
The compiler complains that my_traits::some_trait
already has an initializer. Of course I can specialize it by doing:
template<>
struct my_traits<int>
{
static constexpr int some_trait = 1;
// min and max
};
but then I have to redefine all the other functions, even though they will be exactly the same.
So how can I specialize my_traits<int>::some_trait
without having to repeat min
and max
?