is it ok to specialize std::numeric_limits for user-defined number-like classes?

前端 未结 3 421
猫巷女王i
猫巷女王i 2020-12-03 13:18

The documentation of std::numeric_limits says it should not be specialized for non-fundamental types. What about number-like user-defined types? If I

3条回答
  •  遥遥无期
    2020-12-03 13:49

    Just an example:

    namespace std {
        template<> class numeric_limits {
        public:
           static Temperature lowest() {return Temperature(-273.15f);};
           // One can implement other methods if needed
        };
    }
    

提交回复
热议问题