3

I have my own numeric class:

template<class T>
class Number
{
   // Logic
};

and I'd like to provide values for std::numeric_limits<MyNumber<T>>::min() etc.

I found this answer but it's for non-template classes:

https://stackoverflow.com/a/38670996/1107474

and I'm struggling converting it for templated classes. I was trying:

namespace std 
{
    template<class T> 
    class numeric_limits<Number<T>> 
    {
    public:
        static Number<T> min()
        {
            return Number<T>(1, 0);
        };
    };
}

I get:

template argument 1 is invalid
  279 |     class numeric_limits<Number<T>>
                                         ^
intrigued_66
  • 16,082
  • 51
  • 118
  • 189

0 Answers0