std::ranges::greater
來自 cppreference.com
定義於標頭檔案 <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 的函式物件 (類模板) |