Boost logo

Boost :

From: Andy Little (andy_at_[hidden])
Date: 2005-04-01 04:46:01


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

regards
Andy Little


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