|
Boost : |
Subject: [boost] [rational] Which way should std::numeric_limits::min go?
From: Daryle Walker (darylew_at_[hidden])
Date: 2013-08-21 23:25:04
The default implementation of a std::numeric_limits<T> instantiation is to have all static data member be set to static_cast<X>(0) and all the static member functions return T{}. When an instantiation is manually written, you're supposed to leave members for the types of numbers (integer vs. floating vs...) that you're NOT as in the unimplemented case.
The static member function "min" has a defect. The function "denorm_min" returns the smallest positive value that can be represented (denormalized or not), and is implemented only for floating types. The function "lowest," new to C++11, returns the regular (i.e. not Infinity or NaN, etc.) value closest to negative-infinity. Lowest was introduced because for C++98/03, "min" returned "denorm_min" for the built-in floating types and "lowest" for built-in integer types! You can't get generic code out of that (without checking some more flags from numeric_limits).
Which version of "min" should boost::rational take? I was think of "denorm_min," since I'll be implementing that. The built-in integer types use "lowest" for "min," but don't define the other one at all.
Daryle W.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk