名前空間
変種
操作

std::ratio_less

提供: cppreference.com
< cpp‎ | numeric‎ | ratio
 
 
 
コンパイル時有理数算術
(C++11)
算術
(C++11)
比較
ratio_less
(C++11)
 
ヘッダ <ratio> で定義
template< class R1, class R2 >
struct ratio_less : std::integral_constant<bool, /* see below */> { };
(C++11以上)

有理数 R1 が有理数 R2 より小さければ、 true に等しいメンバ定数 value が提供されます。 そうでなければ、 valuefalse です。

目次

[編集] ヘルパー変数テンプレート

template< class R1, class R2 >
inline constexpr bool ratio_less_v = ratio_less<R1, R2>::value;
(C++17以上)

std::integral_constant から継承

メンバ定数

value
[静的]
R1::num * R2::den < R2::num * R1::den またはオーバーフローを回避したこれと同等な式が成り立つならば true、そうでなければ false
(パブリック静的メンバ定数)

メンバ関数

operator bool
オブジェクトを bool に変換します。 value を返します
(パブリックメンバ関数)
operator()
(C++14)
value を返します
(パブリックメンバ関数)

メンバ型

定義
value_type bool
type std::integral_constant<bool, value>

[編集]

#include <iostream>
#include <ratio>
 
int main()
{
    if (std::ratio_less<std::ratio<23,37>, std::ratio<57,90>>::value) {
        std::cout << "23/37 < 57/90\n";
    }
}

出力:

23/37 < 57/90

[編集] 関連項目