Namespaces
Variants

std::ranges:: greater

From cppreference.net
Utilities library
Function objects
Function invocation
(C++17) (C++23)
Identity function object
(C++20)
Old binders and adaptors
( until C++17* )
( until C++17* )
( until C++17* )
( until C++17* )
( until C++17* ) ( until C++17* ) ( until C++17* ) ( until C++17* )
( until C++20* )
( until C++20* )
( until C++17* ) ( until C++17* )
( until C++17* ) ( until C++17* )

( until C++17* )
( until C++17* ) ( until C++17* ) ( until C++17* ) ( until C++17* )
( until C++20* )
( until C++20* )
定义于头文件 <functional>
struct greater ;
(C++20 起)

用于执行比较的函数对象。从参数推导函数调用运算符的参数类型(但不推导返回类型)。

目录

嵌套类型

嵌套类型 定义
is_transparent 未指定

成员函数

operator()
检查第一个参数是否 大于 第二个参数
(公开成员函数)

std::ranges::greater:: operator()

template < class T, class U >
constexpr bool operator ( ) ( T && t, U && u ) const ;

等价于 return ranges:: less { } ( std:: forward < U > ( u ) , std:: forward < T > ( t ) ) ;

此重载仅当满足 std:: totally_ordered_with < T, U > 概念时参与重载决议。

注释

std::greater 不同, std::ranges::greater 要求所有六个比较运算符 < , <= , > , >= , == != 必须有效(通过 totally_ordered_with 约束实现),并且完全基于 std::ranges::less 进行定义。

示例

缺陷报告

下列行为变更缺陷报告被追溯应用于先前发布的 C++ 标准。

缺陷报告 适用范围 发布时行为 正确行为
LWG 3530 C++20 比较指针时语法检查被放宽 仅放宽语义要求

参见

实现 x > y 的函数对象
(类模板)