Gennaro Prota <[EMAIL PROTECTED]> writes:

> On Wed, 08 Jan 2003 12:08:40 -0500, David Abrahams
> <[EMAIL PROTECTED]> wrote:
>
>>I basically agree with everything you've said, especially about the
>>separate traits (metafunctions)!  I was just pointing out some overlap
>>with existing libraries.
>
> Ok, here's what I propose:
>
> a) cleaning up the whole implementation of boost/detail/limits.hpp by
>
>      - getting rid of all the stuff like:
>
>           template<>
>           class numeric_limits<bool>
>             : public _Integer_limits<bool, false, true, 0>
>           {};
>
>           template<>
>           class numeric_limits<char>
>             : public _Integer_limits<char, CHAR_MIN, CHAR_MAX>
>           {};
>
>           template<>
>           class numeric_limits<signed char>
>             : public _Integer_limits<signed char, SCHAR_MIN,
>           SCHAR_MAX>
>           {};
>
>       because, of course, max_of and min_of can be used for this.
>       Example:
>
>          static T min() throw() { return min_of<T>::value; }
>
>           [Or, if you prefer... ;-)
>
>              return implicit_cast<T> (min_of<T>::value);
>
>           ]

Uh, wait a sec.  Is it a good idea to mess with
boost/detail/limits.hpp?  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.

>    - 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.

>     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.

> b) Modifying integer_traits.hpp to use max_of and min_of. This is
> just for backward compatibility because I think integer_traits
> should be simply deprecated (if the information one wants to provide
> is const_max and const_min for what reason should he add that
> information somewhere else, like numeric_limits<>? And what is the
> derivation good for?)

This was the part I thought I was agreeing with; I don't know.

> What do you think? If there aren't objections I could at least
> upload the needed code to the boost sandbox.
>
> Genny.
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
>

-- 
                       David Abrahams
   [EMAIL PROTECTED] * http://www.boost-consulting.com
Boost support, enhancements, training, and commercial distribution

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Reply via email to