A new feature of the Standard C++ Library is an organized mechanism for describing the characteristics of the fundamental types provided in the execution environment. In older C and C++ libraries, these characteristics were often described by large collections of symbolic constants. For example, the smallest representable value that could be maintained in a character would be found in the constant named CHAR_MIN; the similar constant for a short would be known as SHRT_MIN; a float would be FLT_MIN, and so on.
The template class numeric_limits provides a new and uniform way of representing this information for all numeric types. Instead of using a different symbolic name for each new datatype, the class defines a single static function, named min(), which returns the appropriate values. Specializations of this class then provide the exact value for each supported type. In this way, the smallest character value is found as the result of invoking the function numeric_limits<char>::min(), while the smallest floating point value is found by invoking numeric_limits<float>::min(), and so on.
Using a template class not only greatly reduces the number of symbolic names that need to be defined to describe the operating environment, but it also ensures consistency between the descriptions of the various types.
For the sake of compatibility, the numeric_limits mechanism is used as an addition to the symbolic constants used in older C++ libraries, rather than a strict replacement. Thus both mechanisms exist in parallel for the present. However, as the numeric_limits technique is more uniform and extensible, it should be expected that over time the older symbolic constants will become outmoded.
OEM Edition, ©Copyright 1999, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.