Documentation Home >> Headers >> <ratio> Header >> std::ratio_equal class template

The std::ratio_equal class template provides a mechanism for comparing two std::ratio values for equality at compile time, using rational arithmetic.

template <class R1, class R2>
class ratio_equal:
    public see below

R1 and R2 must be instantiations of the std::ratio class template.

The value of std::ratio_equal<R1,R2> is (R1::num==R2::num) && (R1::den==R2::den).

If the TR1 std::tr1::integral_constant class template is available, then std::ratio_equal<R1,R2> derives from std::tr1::integral_constant<bool, value >. Otherwise, std::ratio_equal<R1,R2> derives from an internal type that provides a static constant data member value of type bool equal to value.

    std::ratio<1,3>, std::ratio<2,6> >::value == true
    std::ratio<1,3>, std::ratio<1,6> >::value == false
    std::ratio<1,3>, std::ratio<2,3> >::value == false
    std::ratio<1,3>, std::ratio<1,3> >::value == true

#include <ratio>

See Also