Boost logo

Boost :

From: Gennaro Prota (gennaro_prota_at_[hidden])
Date: 2003-01-09 14:24:57


Dave, I have shortened the subject since it seemed, so far, to be
changed at each post preventing grouping the messages 'by thread' (at
least with my reader). Now, it should have been changed once for all.

On Thu, 09 Jan 2003 13:21:12 -0500, David Abrahams
<dave_at_[hidden]> wrote:

>Uh, wait a sec. Is it a good idea to mess with
>boost/detail/limits.hpp?

Gulp! I thought I was proposing "simplifying" it, not messing! :-)

>It's just a workaround for broken/missing
>numeric_limits implementations, and it was a pain to get right. Did
>you mention this before? If so, I guess I missed it.

No, I didn't mention it. As I said, I never saw the code before.
Anyway it seems simply copied by some SGI implementation, so I doubt
it was such a pain to get right (no offense intended, really)

>> - in general, calculating values instead of providing them
>> explicitly when this is feasible in a portable way.
>>
>> Example: for built-in integers, instead of having a hack like
>>
>> template <class _Int,
>> _Int __imin,
>> _Int __imax,
>> int __idigits = -1>
>> class _Integer_limits : public _Numeric_limits_base<_Int>
>>
>> that either "calculates" (wrongly) digits or takes the opposite
>> of the value that the user passes (__idigits), we could have:
>>
>> BOOST_STATIC_CONSTANT(int, digits, precision<T>::value);
>
>I guess if you think it's doing something wrong and you can fix it,
>it's worth doing.

It depends on what you mean by "wrong". It works on all the compilers
supported by boost but is uselessly complicated and not portable.

>> Note, as to digits and digits10, that a similar clean up is
>> possible for floating point types too, by adding e.g.:
>>
>>
>> template <typename T> struct digits {
>> BOOST_STATIC_CONSTANT(int, value = 0); // dummy value;
>> (debatable)
>> };
>>
>> template <> struct digits<float>
>> { BOOST_STATIC_CONSTANT(int, value = FLT_MANT_DIG); };
>> template <> struct digits<double>
>> { BOOST_STATIC_CONSTANT(int, value = DBL_MANT_DIG); };
>> template <> struct digits<long double>
>> { BOOST_STATIC_CONSTANT(int, value = LDBL_MANT_DIG);};
>
>Not sure if this will work portably.

Do you mean that we have implementations that don't provide the
x_MANT_DIG macros? Otherwise the code is perfectly portable by
18.2.1.2 of the standard.

Genny.


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