Namespaces
Variants

std:: greater_equal<void>

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>
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 指针全序可能不一致 保证一致性