Looking for arithmetic metafunctions for ratios.

Hi, I'm looking for a metafunction like this: template < class N1, class D1, class N2, class D2 > struct times { typedef ... numer; typedef ... denom; }; N1, D1, N2, and D2 are all MPL integral constant wrappers. The numer member of the times metafunction is the numerator N of the ratio (preferably in reduced form) produced by (N1/D1) * (N2/D2) = (N/D). Likewise, the denom member is the denominator D of the ratio produced from this equation. Any help greatly appreciated. Thanks, Eric.

Hi Eric, "Eric Lemings" <lemings@roguewave.com> wrote in message news:D730FF7CEDDCA64483F9E99D999A158B41FC86@qxvcexch01.ad.quovadx.com... Hi, I'm looking for a metafunction like this: template < class N1, class D1, class N2, class D2 > struct times { typedef ... numer; typedef ... denom; }; N1, D1, N2, and D2 are all MPL integral constant wrappers. The numer member of the times metafunction is the numerator N of the ratio (preferably in reduced form) produced by (N1/D1) * (N2/D2) = (N/D). Likewise, the denom member is the denominator D of the ratio produced from this equation. FWIW Quan http://sourceforge.net/projects/quan has a rational type, you could use as a basis. there is also the mpl_math package in the boost vault, in Template Metaprogramming section I think regards Andy little
participants (2)
-
Andy Little
-
Eric Lemings