The std::ratio_divide
class template provides a mechanism for dividing two std::ratio
values at compile time,
using rational arithmetic.
template <class R1, class R2> class ratio_divide { 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 result
of dividing the fractions represented by R1
and R2
if that result can
be calculated without overflow. In the absence of arithmetic overflow,
std::ratio_divide<R1,R2>::type
shall have the same num
and den
values as std::ratio<R1::num * R2::den, R1::den * R2::num>
.
std::ratio_divide< std::ratio<1,3>, std::ratio<2,5> >::type::num == 5 std::ratio_divide< std::ratio<1,3>, std::ratio<2,5> >::type::den == 6 std::ratio_divide< std::ratio<1,3>, std::ratio<15,7> >::type::num == 7 std::ratio_divide< std::ratio<1,3>, std::ratio<15,7> >::type::den == 45
#include <ratio>