less_equal
描述 (Description)
它是一个函数对象类,用于小于或等于比较和二元函数对象类,其调用返回其第一个参数是否小于或等于第二个参数(由operator <=返回)。
声明 (Declaration)
以下是std :: less_equal的声明。
template <class T> struct less_equal;
C++11
template <class T> struct less_equal;
参数 (Parameters)
T - 它是函数调用的参数和返回类型的一种类型。
返回值 (Return Value)
没有
异常 (Exceptions)
noexcep - 它不会抛出任何异常。
例子 (Example)
在下面的例子中解释了std :: less_equal。
#include <iostream>
#include <functional>
#include <algorithm>
int main () {
int numbers[]={250,500,70,100,125};
int cx = std::count_if (numbers, numbers+5, std::bind2nd(std::less_equal<int>(),100));
std::cout << "There are " << cx << " elements lower than or equal to 100.\n";
return 0;
}
让我们编译并运行上面的程序,这将产生以下结果 -
There are 2 elements lower than or equal to 100