template <class R1, class R2> ratio_divide;
12
template <typename R1, typename R2> using ratio_add = ratio < R1::num *R2::den, R2::num*R1::den>;
12345678910111213141516
// ratio_divide example #include <iostream> #include <ratio> int main () { typedef std::ratio<1,2> one_half; typedef std::ratio<1,3> one_third; typedef std::ratio_divide<one_half,one_third> result; std::cout << "result = " << result::num << "/" << result::den; std::cout << " (which is: " << ( double(result::num) / result::den ) << ")" << std::endl; return 0; }
result = 3/2 (which is: 1.5)