std::less_equal<void>

来自cppreference.com
< cpp‎ | utility‎ | functional
 
 
工具库
语言支持
类型支持(基本类型、RTTI)
库功能特性测试宏 (C++20)
动态内存管理
程序工具
协程支持 (C++20)
变参数函数
调试支持
(C++26)
三路比较
(C++20)
(C++20)(C++20)(C++20)
(C++20)(C++20)(C++20)
通用工具
日期和时间
函数对象
格式化库 (C++20)
(C++11)
关系运算符 (C++20 中弃用)
整数比较函数
(C++20)(C++20)(C++20)   
(C++20)
交换类型运算
(C++14)
(C++11)
(C++11)
(C++11)
(C++17)
常用词汇类型
(C++11)
(C++17)
(C++17)
(C++17)
(C++11)
(C++17)
(C++23)
初等字符串转换
(C++17)
(C++17)

 
函数对象
函数调用
(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)
less_equal<>
(C++14)

旧式绑定器与适配器
(C++17 前*)
(C++17 前*)
(C++17 前*)
(C++17 前*)
(C++17 前*)(C++17 前*)(C++17 前*)(C++17 前*)
(C++20 前*)
(C++20 前*)
(C++17 前*)(C++17 前*)
(C++17 前*)(C++17 前*)

(C++17 前*)
(C++17 前*)(C++17 前*)(C++17 前*)(C++17 前*)
(C++20 前*)
(C++20 前*)
 
在标头 <functional> 定义
template<>
class less_equal<void>;
(C++14 起)

std::less_equal<void> 是会推导形参类型和返回类型的 std::less_equal 特化。

嵌套类型

嵌套类型 定义
is_transparent 未指定

成员函数

operator()
测试 lhs 是否小于或等于 rhs
(公开成员函数)

std::less_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_positive(int lhs)
{
    return std::less_equal<>()(lhs, 0);
}
 
int main()
{
    constexpr int low = 0, high = 8;
    std::less_equal<> less_equal{};
    static_assert(less_equal(low, high));
    static_assert(less_equal(low, low));
 
    static constexpr auto arr = {1, 0, -1, -2, -3, -4};
    static_assert(!std::all_of(arr.begin(), arr.end(), strictly_not_positive));
    static_assert(std::all_of(arr.begin() + 1, arr.end(), strictly_not_positive));
}

缺陷报告

下列更改行为的缺陷报告追溯地应用于以前出版的 C++ 标准。

缺陷报告 应用于 出版时的行为 正确行为
LWG 2562 C++98 指针全序可能不一致 保证一致