C++ 函式庫 - greater_equal



描述

它是一個用於大於或等於比較的功能物件類,以及一個二元函式物件類,其呼叫返回其第一個引數是否大於或等於第二個引數(由運算子 >= 返回)。

宣告

以下是 std::greater_equal 的宣告。

template <class T> struct greater_equal;

C++11

template <class T> struct greater_equal;

引數

T − 它表示函式呼叫的引數和返回值的型別。

返回值

異常

noexcep − 它不丟擲任何異常。

示例

下面的示例說明了 std::greater_equal 的用法。

#include <iostream>
#include <functional>
#include <algorithm>

int main () {
   int numbers[]={200,-30,10,-40,0};
   int cx = std::count_if (numbers, numbers+5, std::bind2nd(std::greater_equal<int>(),0));
   std::cout << "There are " << cx << " non-negative elements.\n";
   return 0;
}

讓我們編譯並執行上述程式,這將產生以下結果:

There are 3 non-negative elements. 
functional.htm
廣告