Boost logo

Boost :

From: Jonathan Turkanis (technews_at_[hidden])
Date: 2005-04-04 16:15:34

Andy Little wrote:
> "Jonathan Turkanis" <technews_at_[hidden]> wrote
>> Andy Little wrote:
>>> BTW why doesnt boost::rational have a 'value_type' member rather
>>> than the obscure 'int_type'?
>> You'd have to ask Paul. I would guess it's mean to reflect the
>> requirements on the template parameter.
> If you are using a rational , you are kind of going to figure out
> that the value_type should be an integer... I hope.

It's also documented, of course. But my point was that name was chosen to suit
the problem domain.

> OTOH this
> requirement can be imposed.
> However rational should be seen as one of a family of UDT
> value_type-operable types. (std::complex , boost::rational and
> boost::interval can all be Op'ed with their value_type. And in fact
> have a remarkably similar set of function signatures)
> The nearest precedent in the standard is complex which does have a
> 'value_type' member. In using UDTs that implement numeric types it is
> reasonably common to want to know the 'value_type', for which purpose
> I use a to_value_type<T> function, which by default recursively
> inspects T::value_type for non-inbuilt types. In determining rational
> (and incidentally interval) value_types I have had to create
> specialisations which is tedious. There seems to be no particular
> reason not to follow the standard name for the value_type in either
> rational or interval.

The best way to provide a uniform interface for these types would be to provide
a TR1 tuple interface. This would be compatible with keeping the name int_type.


Boost list run by bdawes at, gregod at, cpdaniel at, john at