The std::greater is a functional object which is used for performing comparisons. It is defined as a Function object class for the greater-than inequality comparison. This can be used for changing the functionality of the given function. This can also be used with various standard algorithms such as sort, priority queue, etc.
template <class T> struct greater;
Parameter: T is a type of the arguments to compare by the functional call.
Return Value: It returns boolean variable as shown below:
- True: If two element say(a & b) such that a > b.
- False: If a < b.
Below is the illustration of std::greater in C++:
90 80 70 60 50 40 30 20 10
The priority queue gquiz is : 1 5 10 20 30
GeeksforGeeks has prepared a complete interview preparation course with premium videos, theory, practice problems, TA support and many more features. Please refer Placement 100 for details
- cin get() in C++ with Examples
- std::less in C++ with Examples
- Pi(π) in C++ with Examples
- std::greater_equal in C++ with Examples
- C/C++ For loop with Examples
- ratio_not_equal() in C++ with examples
- wmemset() in C/C++ with Examples
- std::bit_xor in C++ with Examples
- basic_istream::get() in C++ with Examples
- std::has_virtual_destructor in C++ with Examples
- std::allocator() in C++ with Examples
- Map of Vectors in C++ STL with Examples
- feclearexcept in C++ with Examples
- std::bit_or in C++ with Examples
- std::is_heap( ) in C++ with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.