當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


C# greater_equal用法及代碼示例


描述

它是一個函數對象類,用於 greater-than-or-equal-to 比較和二元函數對象類,其調用返回其第一個參數是否大於或等於第二個參數(由運算符 >= 返回)。

聲明

以下是 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. 

相關用法


注:本文由純淨天空篩選整理自 C++ Functional Library - greater_equal。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。