名前空間
変種

std::ratio_not_equal

提供: cppreference.com
 
 
 
 
<tbody> </tbody>
ヘッダ <ratio> で定義
template< class R1, class R2 > struct ratio_not_equal : std::integral_constant<bool, /* see below */> { };
(C++11以上)

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

ヘルパー変数テンプレート

<tbody> </tbody>
template< class R1, class R2 > inline constexpr bool ratio_not_equal_v = ratio_not_equal<R1, R2>::value;
(C++17以上)

std::integral_constant から継承

メンバ定数

value
[静的]
R1::num != R2::num || R1::den != R2::den ならば true、そうでなければ false
(パブリック静的メンバ定数)

メンバ関数

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

メンバ型

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

実装例

template< class R1, class R2 >
struct ratio_not_equal : std::integral_constant <
                              bool,
                              !std::ratio_equal<R1, R2>
                         > {};

#include <iostream>
#include <ratio>

int main()
{
    if(std::ratio_not_equal<std::ratio<2,3>, std::ratio<1,3>>::value) {
        std::cout << "2/3 != 1/3\n";
    } else {
        std::cout << "2/3 == 1/3\n";
    }
}

出力:

2/3 != 1/3

関連項目

Morty Proxy This is a proxified and sanitized view of the page, visit original site.