class template
<ratio>
std::ratio_less
template <class R1, class R2> ratio_less;
Compare ratios for less-than inequality
This type inherits from the appropriate integral_constant type (either true_type or false_type) to signal whether R1 compares less than R2
The resulting type is the same as if ratio_less was defined as:
1 2
|
template <class R1, class R2>
struct ratio_less : integral_constant < bool, R1::num*R2::den < R2::num*R1::den > {};
| |
A program shall not cause any expression in the above definition to expand to values not representable as an
intmax_t.
Template parameters
- R1,R2
- ratio types to be compared.
Member constants
Inherited from integral_constant:
member constant | definition |
value | either true or false |
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
// ratio_less example
#include <iostream>
#include <ratio>
int main ()
{
typedef std::ratio<1,3> one_third;
typedef std::ratio<1,2> one_half;
std::cout << "1/3 < 1/2 ? " << std::boolalpha;
std::cout << std::ratio_less<one_third,one_half>::value << std::endl;
return 0;
}
| |
Output:
See also
- ratio_greater
- Compare ratios for greater than inequality (class template
)
- ratio_less_equal
- Compare ratios for equality or less-than inequality (class template
)
- ratio_equal
- Compare ratios (class template
)