Boost logo

Boost :

From: Beman Dawes (beman_at_[hidden])
Date: 1999-08-06 12:59:26


At 05:59 PM 8/6/99 +0200, Valentin Bonnard wrote:

>Beman Dawes wrote:
>
>> For many uses, these are sufficient. But min() and max() are
>> problems because they are not constant expressions (5.19) and some
>> uses require constant expressions.
>
>Like C array declarations, cases in switch
>and integral template parameters
>
>> Valentin worked around this by providing an
extended_numeric_limits<>
>> class derived from numeric_limits<>, which for integers added:
>>
>> static const T max_constant;
>> static const T min_constant;
>>
>> (I have changed lots of details from Valentin's header for the
sake
>> of exposition.)
>>
>> Now the 64-bit question:
>
>I would go as a far as 128 bits.
>
>> Is it worthwhile for boost to supply an
extended_numeric_limits<>
>> class?
>>
>> To me, it seems more trouble that it is worth. What do others
think?
>
>Simply indispensable for my integral types library.

What is the usage? Does it really require a constant expression, or
would std::numeric_limits<T>::max() or std::numeric_limits<T>::min()
do?

>Trivial to define in term of <climits>.

Nothing is trivial that involves a new header, educating users, etc.
The implementation is certainly trivial if you don't mind using the
<climits> macros.

It seems to me that this is really a hole in the C++ standard's
numeric_limits<>. Was there ever discussion of providing constant
expression forms of max and min for integers? Can anyone remember
the rationale for not doing so?

--Beman


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk