Topic: The declarations in <limits>
Author: endh1b@right.now (Marcus Vinicius)
Date: 1999/04/22 Raw View
Could anyone explain the logic behind the declarations in <limits>?
I can't see the value of declaring the limits as static member functions. This
appears to prevent their use in declaring array bounds or other places where
constant expressions are needed. It would seem that programmers have to rely
on the old C macros....or am I missing something?
John - N8086N
Wise man says "Never use a bank with the initials F. U."
-------------------------------------------
Are you interested in a professional society or
guild for programmers? Want to fight section 1706?
See www.programmersguild.org
Newsgroup: us.issues.occupations.computer-programmers
EMail Address:
_m-i-a-n-o_@_c_o_l_o_s_s_e_u_m_b_u_i_l_d_e_r_s._c_o_m_
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: Valentin Bonnard <Bonnard.V@wanadoo.fr>
Date: 1999/04/22 Raw View
Marcus Vinicius wrote:
>
> Could anyone explain the logic behind the declarations in <limits>?
numerical_limits is applicable to all types, not just integral types
(ie bool, [unsigned/signed] char, wchar_t, [unsigned] short, [unsigned]
int, [unsigned] long). numerical_limits can be specialised for user
defined types and is specialised for floating point types.
max and min have to be functions in the general case.
> I can't see the value of declaring the limits as static member functions. This
> appears to prevent their use in declaring array bounds or other places where
> constant expressions are needed. It would seem that programmers have to rely
> on the old C macros....or am I missing something?
I have written a template class xnumerical_limits, which has
compile time constant members cmax and cmin (for integral types):
http://www.eleves.ens.fr:8080/home/bonnard/NewLibs/NumericalTypes
/doc/IntTypes.html#xnum_limits
--
Valentin Bonnard
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]