A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://cplusplus.com/reference/functional/greater_equal/ below:

class template

<functional>

std::greater_equal
template <class T> struct greater_equal;

Function object class for greater-than-or-equal-to comparison

Binary function object class whose call returns whether the its first argument compares greater than or equal to the second (as returned by operator >=).

Generically, function objects are instances of a class with member function operator() defined. This member function allows the object to be used with the same syntax as a function call.

It is defined with the same behavior as:

1
2
3
template <class T> struct greater_equal : binary_function <T,T,bool> {
  bool operator() (const T& x, const T& y) const {return x>=y;}
};
1
2
3
4
5
6
template <class T> struct greater_equal {
  bool operator() (const T& x, const T& y) const {return x>=y;}
  typedef T first_argument_type;
  typedef T second_argument_type;
  typedef bool result_type;
};


Objects of this class can be used on standard algorithms such as sort, merge or lower_bound.

Template parameters
T
Type of the arguments to compare by the functional call.
The type shall support the operation (operator>=).

Member types member type definition notes first_argument_type T Type of the first argument in member operator() second_argument_type T Type of the second argument in member operator() result_type bool Type returned by member operator()
Member functions
bool operator() (const T& x, const T& y)
Member function returning whether the first argument compares greater than or equal to the second (x>=y).

Example
1
2
3
4
5
6
7
8
9
10
11
// greater_equal example
#include <iostream>     // std::cout
#include <functional>   // std::greater_equal, std::bind2nd
#include <algorithm>    // std::count_if

int main () {
  int numbers[]={20,-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;
}

Output:
There are 3 non-negative elements.


See also
equal_to
Function object class for equality comparison (class template)
not_equal_to
Function object class for non-equality comparison (class template)
greater
Function object class for greater-than inequality comparison (class template)
less
Function object class for less-than inequality comparison (class template)
less_equal
Function object class for less-than-or-equal-to comparison (class template)

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4