Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

In the C++ Standard Library the value std::numeric_limits<T>::max() is specified as a function. Further properties of a specific type are given as constants (likestd::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.

What's the rationale behind that?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
217 views
Welcome To Ask or Share your Answers For Others

1 Answer

To expand on Neil's remark, std::numeric_limit<T> is available for any number type including floating point numbers, 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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...