std::ratio_not_equal
來自 cppreference.com
定義於標頭檔案 <ratio> |
||
template< class R1, class R2 > struct ratio_not_equal : std::integral_constant<bool, /* see below */> { }; |
(C++11 起) | |
如果比例 R1
和 R2
不相等,則提供成員常量 value 等於 true。否則,value 為 false。
目錄 |
[編輯] 輔助變數模板
template< class R1, class R2 > 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 (public static 成員常量) |
成員函式
operator bool |
將物件轉換為 bool,返回 value (公開成員函式) |
operator() (C++14) |
返回 value (公開成員函式) |
成員型別
型別 | 定義 |
value_type
|
bool |
型別
|
std::integral_constant<bool, value> |
[編輯] 可能實現
template< class R1, class R2 > struct ratio_not_equal : std::integral_constant < bool, !std::ratio_equal<R1, R2> > {}; |
[編輯] 示例
執行此程式碼
#include <ratio> static_assert(std::ratio_not_equal_v<std::ratio<6, 9>, std::ratio<9, 6>>, "6/9 != 9/6"); int main() {}
[編輯] 另請參閱
(C++11) |
在編譯時比較兩個 ratio 物件是否相等(類模板) |