命名空间
变体
操作

std::ratio_greater_equal

来自 cppreference.cn
< cpp‎ | 数值‎ | ratio
 
 
元编程库
类型特性
类型类别
(C++11)
(C++11)(DR*)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11) 
(C++11)
(C++11)
类型属性
(C++11)
(C++11)
(C++14)
(C++11)(C++26 中已弃用)
(C++11)(直到 C++20*)
(C++11)(C++20 中已弃用)
(C++11)
类型特性常量
元函数
(C++17)
支持的操作
关系与属性查询
类型修改
(C++11)(C++11)(C++11)
类型转换
(C++11)(C++23 中已弃用)
(C++11)(C++23 中已弃用)
(C++11)
(C++11)(直到 C++20*)(C++17)

(C++11)
(C++17)
编译时有理数算术
编译时整数序列
 
编译时有理数算术
(C++11)
算术
(C++11)
比较
(C++11)
ratio_greater_equal
(C++11)
 
定义于头文件 <ratio>
template< class R1, class R2 >
struct ratio_greater_equal : std::integral_constant<bool, /* 参见下方 */> { };
(C++11 起)

如果比值 R1 大于或等于比值 R2,则提供成员常量 value 等于 true。否则,valuefalse

目录

[edit] 辅助变量模板

template< class R1, class R2 >
constexpr bool ratio_greater_equal_v = ratio_greater_equal<R1, R2>::value;
(C++17 起)

继承自 std::integral_constant

成员常量

value
[静态]
true 如果 R1::num * R2::den >= R2::num * R1::den,或等效的避免溢出的表达式,否则为 false
(public static 成员常量)

成员函数

operator bool
将对象转换为 bool,返回 value
(公开成员函数)
operator()
(C++14)
返回 value
(公开成员函数)

成员类型

类型 定义
value_type bool
类型 std::integral_constant<bool, value>

[edit] 示例

#include <ratio>
 
int main()
{
    static_assert(std::ratio_greater_equal<
        std::ratio<2, 3>,
        std::ratio<2, 3>>::value, "2/3 >= 2/3");
 
    // since C++17
    static_assert(std::ratio_greater_equal_v<
        std::ratio<999'998, 999'999>,
        std::ratio<999'997, 999'998>>);
}

[edit] 参阅

在编译时比较两个 ratio 对象是否相等
(类模板) [edit]
在编译时比较两个 ratio 对象是否“小于”
(类模板) [edit]