Boost logo

Boost :

From: Daryle Walker (darylew_at_[hidden])
Date: 2002-01-03 22:44:53


on 1/3/02 9:25 PM, Jens Maurer at Jens.Maurer_at_[hidden] wrote:

> Daryle Walker wrote:
[SNIP]
[Jens wrote:]
>>> - I don't like the extrema templates. I'd like to see
>>> the integral type as a template parameter, and not as a
>>> fixed "long/unsigned long" choice. Reasons:
>>
>> Those templates return the appropriately-sized type for the given value
>> anyway. If you specify the integral type as a template parameter, then you
>> already know the range of numbers needed, and so don't need to use the
>> templates!
>
> The documentation appears to be lacking, because it doesn't
> specify the type of "value" at all. It would really help
> to see the definition of the various classes instead of just
> their declaration.

> And, looking at the implementation, there is indeed no type
> magic going on: boost/integer/static_min_max.hpp says the
> value is just of type "long" or "unsigned long".
>
> And now back to my point: Since this is a min/max template,
> one of the arguments will be returned. And, usually, I know
> the type/size of the arguments, so I can transmit it.
> (This is all compile-time.)
>
> template<class T, T value1, T value2>
> struct static_min
> {
> BOOST_STATIC_CONSTANT(T, value = /* as usual */);
> };
>
> // this usually required definition is currently lacking as well
> #ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
> template<class T, T value1, T value2>
> const T static_min<T, value1, value2>::value;
> #endif
>
>
> I still believe this template is a natural expansion and
> merge of the currently available static_signed_min and
> static_unsigned_min templates.
>
> Please argue specifically why the current state of affairs
> in boost/integer/static_min_max.hpp is better than the
> suggestion above.
>
> (Similarly with static_max.)

Actually, I thought you were talking about a different file. I thought you
meant the fitting templates I added to <boost/integer.hpp>, but you mean the
stuff in the new <boost/integer/static_min_max.hpp>. So ignore my comments.

Your idea sounds OK.

>>> * There are compilers where "long long" is actually an
>>> integral type. Currently, I am not able to use boost's
>>> compile-time min/max with values of that type.
>>
>> I've heard that some compilers that support "long long" and "unsigned long
>> long" don't support them as types for value-based template parameters.
>
> gcc does so.

GCC does or does not have support? Either way, GCC's answer doesn't reflect
on what other compilers may support.

-- 
Daryle Walker
Mac, Internet, and Video Game Junkie
darylew AT mac DOT com

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