std::less_equal<void>
来自 cppreference.cn
定义于头文件 <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 |
||
返回 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 | 指针全序可能不一致 | 保证一致 |