2

Possible Duplicate:
Why is std::numeric_limits<T>::max() a function?

why numeric_limits<T>::has_infinity is a const value and numeric_limits<T>::infinity is not? why make numeric_limits<T>::infinity a function?

Community
  • 1
  • 1

1 Answers1

4

Because things like float, double or UDT static const values cannot be initialized in class and need an external definition. In simple words they need a memory location, while static const integral values do not (as long as a pointer/reference to them is not taken).

In C++11 these functions should be declared constexpr, which defeats any shortcoming you may be seeing from the fact that they are functions instead of constants.

K-ballo
  • 80,396
  • 20
  • 159
  • 169