類模板
<ratio>

std::ratio_less_equal

template <class R1, class R2> ratio_less_equal;
比較 ratio 的相等或小於關係
此型別繼承自適當的 integral_constant 型別(true_typefalse_type),用於指示 R1 是否小於或等於 R2
結果型別與以下定義相同:ratio_less_equal定義為
1
2
template <class R1, class R2>
struct ratio_less_equal : integral_constant < bool, !ratio_less<R2,R1>::value > {};

模板引數

R1,R2
要比較的 ratio 型別。

成員常量

繼承自 integral_constant
成員常量定義
truefalse

成員型別

繼承自 integral_constant
成員型別定義
value_typebool
型別true_type 或 false_type

示例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
// ratio_less_equal 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_equal<one_third,one_half>::value << std::endl;

  return 0;
}

輸出
1/3 <= 1/2 ? true


另見