class template
<functional>
std::lesstemplate <class T> struct less;
Function object class for less-than inequality comparison
Binary function object class whose call returns whether the its first argument compares less than 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 less : 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 less {
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;
};
operator()
second_argument_type T Type of the second argument in member operator()
result_type bool Type returned by member operator()
x<y
).
1
2
3
4
5
6
7
8
9
10
11
12
13
14
// less example
#include <iostream> // std::cout
#include <functional> // std::less
#include <algorithm> // std::sort, std::includes
int main () {
int foo[]={10,20,5,15,25};
int bar[]={15,10,20};
std::sort (foo, foo+5, std::less<int>()); // 5 10 15 20 25
std::sort (bar, bar+3, std::less<int>()); // 10 15 20
if (std::includes (foo, foo+5, bar, bar+3, std::less<int>()))
std::cout << "foo includes bar.\n";
return 0;
}
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