名稱空間
變體
操作

std::greater_equal<void>

來自 cppreference.com
 
 
 
函式物件
函式呼叫
(C++17)(C++23)
恆等函式物件
(C++20)
透明運算子包裝器
(C++14)
(C++14)
(C++14)
(C++14)  
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)
(C++14)
greater_equal<>
(C++14)

舊繫結器和介面卡
(直到 C++17*)
(直到 C++17*)
(直到 C++17*)
(直到 C++17*)  
(直到 C++17*)
(until C++17*)(until C++17*)(until C++17*)(until C++17*)
(直到 C++20*)
(直到 C++20*)
(直到 C++17*)(直到 C++17*)
(直到 C++17*)(直到 C++17*)

(直到 C++17*)
(until C++17*)(until C++17*)(until C++17*)(until C++17*)
(直到 C++20*)
(直到 C++20*)
 
定義於標頭檔案 <functional>
template<>
class greater_equal<void>;
(C++14 起)

std::greater_equal<void>std::greater_equal 的一個特化,其引數和返回型別由推導得出。

目錄

[編輯] 巢狀型別

巢狀型別 定義
is_transparent 未指定

[編輯] 成員函式

operator()
測試 lhs 是否大於或等於 rhs
(公開成員函式)

std::greater_equal<void>::operator()

template< class T, class U >

constexpr auto operator()( T&& lhs, U&& rhs ) const

    -> decltype(std::forward<T>(lhs) >= std::forward<U>(rhs));

返回 std::forward<T>(lhs) >= std::forward<U>(rhs) 的結果。

引數

lhs, rhs - 要比較的值

返回值

std::forward<T>(lhs) >= std::forward<U>(rhs).

若呼叫內建的指標比較運算子,則結果與對指標的實現定義嚴格全序一致。

[編輯] 異常

可能丟擲實現定義的異常。

[編輯] 示例

#include <algorithm>
#include <functional>
#include <initializer_list>
 
constexpr bool strictly_not_negative(int lhs)
{
    return std::greater_equal<>()(lhs, 0);
}
 
int main()
{
    constexpr int low = 0, high = 8;
    std::greater_equal<> greater_equal{};
    static_assert(greater_equal(high, low));
    static_assert(greater_equal(low, low));
 
    static constexpr auto arr = {-1, 0, 1, 2, 3, 4};
    static_assert(!std::all_of(arr.begin(), arr.end(), strictly_not_negative));
    static_assert(std::all_of(arr.begin() + 1, arr.end(), strictly_not_negative));
}

[編輯] 缺陷報告

下列更改行為的缺陷報告追溯地應用於以前出版的 C++ 標準。

缺陷報告 應用於 釋出時的行為 正確的行為
LWG 2562 C++98 指標全序可能不一致 保證一致