views:

242

answers:

1

In the standard library of C++ the value std::numeric_limits<T>::max() is specified as a function. Further properties of a specific type are given as constants (like std::numeric_limits<T>::is_signed). All constants that are of type T are given as functions, whereas all other constants are given as, well, constant values.

Whats the rationale behind that?

+6  A: 

To expand on Neil remark: std::numeric_limit<T> is available for any number type including floating points number and if you dig through the comp.lang.c++ thread you'll see the mention that it might not be possible to define the static variables for floating point values.

So for consistency they decided to put both integral and floating points behind methods.

It will change with C++0x, so there's hope.

Matthieu M.