Boost logo

Boost :

Subject: Re: [boost] [Review] Boost.Ratio
From: joel falcou (joel.falcou_at_[hidden])
Date: 2010-10-09 02:16:56


On 09/10/10 00:16, vicente.botet wrote:
> The idea is to specialize mpl arithmetic operation for ratio. As Ratio is not a Integral Constants we need to define a new on, let me call it Rational Constant. What could be the requirements for a Rational Constant?
>
> Expression Type Complexity
> r::tag rational_c_tag Constant time.
> r::value_type A boost::rational<integral_type> type Constant time.
> r::num An integral constant expression Constant time.
> r::den An integral constant expression Constant time.
> r::type Rational Constant Constant time.
> r::value_type c = r.value() R::value_type Constant time.
>
> Expression Semantics
> r::tag r's tag type; n::tag::value is n's conversion rank.
> r::num The value of the numerator integral constant.
> r::den The value of the denominator integral constant.
> r::type 'is_equivalent'<r::type,r>::value == true.
> c=r.value() c.numerator() * r::den == c.denominator() * r::num.
>
> I could implemented this, but before doing it I will want to heard the maintainers of MPL about this feature and if they will accept to include it in his library.
>
Oh the idea was not to include ratio in MPL but just make ratio expose
the needed inner type so you could drop any ratio type into mpl operations.
> Respect to fusion adaptors, I don't see what can be done. Could detal a little bit more:
>

Basically, soemtime I needed to acces the numerator or denominator
through fusion::at_c or apply fusion::for_each on them.

int n = fusion::at_c<0>( some_ratio );

I can make the adaptor if you want, it's like 20 lines. It can sit in an
optional file (much like ratio_io) and be included only if needed.

> I will be glad to see how you applied ratio. Could you share?
Sure, I'll post this once I go back to my office.


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