template <class R1, class R2> ratio_equal;
12
template <class R1, class R2> struct ratio_equal : integral_constant<bool, R1::num==R2::num && R1::den==R2::den> {};
1234567891011121314
// ratio_equal example #include <iostream> #include <ratio> int main () { typedef std::ratio<1,2> one_half; typedef std::ratio<2,4> two_fourths; std::cout << "1/2 == 2/4 ? " << std::boolalpha; std::cout << std::ratio_equal<one_half,two_fourths>::value << std::endl; return 0; }
1/2 == 2/4 ? true