|
Boost : |
Subject: Re: [boost] [Review] Boost.Ratio
From: vicente.botet (vicente.botet_at_[hidden])
Date: 2010-10-09 10:17:37
----- Original Message -----
From: "joel falcou" <joel.falcou_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Saturday, October 09, 2010 8:16 AM
Subject: Re: [boost] [Review] Boost.Ratio
>
> 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.
As far as I know this the mpl operations could not be compatible with tha Rational constant concept. Please give a depth description of what are you seen that I don't see.
>> 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.
Please post these lines and I will see if this can be intergrated into Boost.Ratio.
Best,
Vicente
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk