I have a class to describe some type attributes.
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 in this:
template<> struct my_traits<int> { static constexpr int some_trait = 1;
but then I have to redefine all the other functions, although they will be exactly the same.
So, how can I specialize my_traits<int>::some_trait without repeating min and max ?
c ++ c ++ 14 template-specialization
maddisoj
source share