<ratio>

コンパイル時に有理数を格納および操作するために使用されるテンプレートおよび定数を定義する標準ヘッダー <ratio> を含めます。

#include <ratio>

Hh874762.collapse_all(ja-jp,VS.110).gif比率の構造

template <intmax_t N, intmax_t D = 1>
struct ratio
{
    static constexpr intmax_t num;
    static constexpr intmax_t den;
    typedef ratio<num, den> type;
};

ratio Structure は num、または den の == N または D と num と den よくあるファクタはありません。静的 num 定数と den をそのうち定義します。num / den はです value テンプレート クラスによって表される。したがって、type は num の == N0 と den の == D0 インスタンス化 ratio<N0, D0> を示します。

Hh874762.collapse_all(ja-jp,VS.110).gif特殊化

<ratio> は、次の形式にする ratio の特殊化を定義します。

template <class R1, class R2> struct ratio_specialization

各特殊化は、ratioの特殊化である 2 種類のテンプレートのパラメーターを受け取ります。type の値は、関連の論理演算によって決まります。

名前

type 値

ratio_add

R1 + R2

ratio_divide

R1 / R2

ratio_equal

R1 == R2

ratio_greater

R1 > R2

ratio_greater_equal

R1 >= R2

ratio_less

R1 < R2

ratio_less_equal

R1 <= R2

ratio_multiply

R1 * R2

ratio_not_equal

!(R1 == R2)

ratio_subtract

R1 - R2

Hh874762.collapse_all(ja-jp,VS.110).giftypedef

typedef ratio<1,        1000000000000000000> atto;
typedef ratio<1,           1000000000000000> femto;
typedef ratio<1,              1000000000000> pico;
typedef ratio<1,                 1000000000> nano;
typedef ratio<1,                    1000000> micro;
typedef ratio<1,                       1000> milli;
typedef ratio<1,                        100> centi;
typedef ratio<1,                         10> deci;
typedef ratio<                        10, 1> deca;
typedef ratio<                       100, 1> hecto;
typedef ratio<                      1000, 1> kilo;
typedef ratio<                   1000000, 1> mega;
typedef ratio<                1000000000, 1> giga;
typedef ratio<             1000000000000, 1> tera;
typedef ratio<          1000000000000000, 1> peta;
typedef ratio<       1000000000000000000, 1> exa;

参照

その他の技術情報

ヘッダー ファイル