greater


A binary function object that returns true if its first operand is greater than its second operand.

Library

Standards<ToolKit>

Declaration


#include <functional>

template< class T >
struct greater : binary_function< T, T, bool >

Interface

()
bool operator()( const T& x , const T& y ) const
Returns x > y .
Example <ospace/osstd/examples/greater.cpp>
#include <iostream>
#include <algorithm>
#include <functional>

int array[ 4 ] = { 3, 1, 4, 2 };

void
main()
  {
  sort( array, array + 4, greater< int >() );

  for ( int i = 0; i < 4; ++i )
    cout << array[ i ] << "\n";
  }

4
3
2
1

Copyright©1994-2026 Recursion Software LLC
All Rights Reserved - For use by licensed users only.