Boost logo

Boost :

Subject: Re: [boost] [chrono] type_traits/common_type and integer/ratio
From: vicente.botet (vicente.botet_at_[hidden])
Date: 2009-12-06 04:36:49


----- Original Message -----
From: "Vicente Botet Escriba" <vicente.botet_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Thursday, December 03, 2009 4:17 AM
Subject: Re: [boost] [chrono] type_traits/common_type and integer/ratio

>
>
>
> Hi Johm,
>
>
> John Maddock wrote:

>> This one's quite a bit of an addition - almost a little mini-library in
>> it's
>> own right.
>>
>> I think you're correct that it should be locatable as a utility in it's
>> own
>> right, and yes under boost/integer I guess. My suggestion is that you ask
>> for a review for ratio separately from chrono. BTW the utilities here
>> http://www.boost.org/doc/libs/1_41_0/libs/math/doc/gcd/html/index.html
>> might
>> be useful for the implementation of this one, rather than re-inventing
>> your
>> own.
>
> Thanks for the pointer. I'll see how math/gdc can be used to refactor the
> use of gdc in the class ratio.

Hi,

I hav refactored boost/ratio;hpp to use math::static_gcd instead of the internal detail::static_gcd, and this is working now. In the detail implementation there was also the following metafunctions

  template <boost::intmax_t X>
  struct static_abs
  {
      static const boost::intmax_t value = X < 0 ? -X : X;
  };

  template <boost::intmax_t X>
  struct static_sign
  {
      static const boost::intmax_t value = X == 0 ? 0 : (X < 0 ? -1 : 1);
  };

Is there something similar in Boost.Math or elsewhere?

Thanks,
Vicente


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