The std::ratio_multiply
class template provides a mechanism for multiplying two std::ratio values at compile time,
using rational arithmetic.
template <class R1, class R2> class ratio_multiply { public: typedef std::ratio<see below> type; };
R1 and R2
must be instantiations of the std::ratio class template.
The member typedef type
is defined to be an instantiation of std::ratio that represents the product
of the fractions represented by R1
and R2 if that product
can be calculated without overflow. In the absence of arithmetic overflow,
std::ratio_multiply<R1,R2>::type
shall have the same num
and den values as std::ratio<R1::num * R2::num, R1::den * R2::den>.
std::ratio_multiply< std::ratio<1,3>, std::ratio<2,5> >::type::num == 2 std::ratio_multiply< std::ratio<1,3>, std::ratio<2,5> >::type::den == 15 std::ratio_multiply< std::ratio<1,3>, std::ratio<15,7> >::type::num == 5 std::ratio_multiply< std::ratio<1,3>, std::ratio<15,7> >::type::den == 7
Header
#include <ratio>