mirror of
https://gitlab.com/fbb-git/cppannotations
synced 2024-11-18 10:06:54 +01:00
f61c34b9c7
git-svn-id: https://cppannotations.svn.sourceforge.net/svnroot/cppannotations/trunk@432 f6dd340e-d3f9-0310-b409-bdd246841980
39 lines
2.1 KiB
Text
39 lines
2.1 KiB
Text
The relational operators are called by the
|
|
hi(function object: relational)hi(relational function object) relational
|
|
function objects. All standard relational operators are supported: tt(==, !=,
|
|
>, >=, <) and tt(<=).
|
|
|
|
The STL supports the following set of relational function objects:
|
|
itemization(
|
|
itht(equal_to)(equal_to>): this object's tt(operator()) member calls
|
|
ti(operator==),
|
|
passing the latter operator its two parameter values
|
|
and returning the latter operator's return value.
|
|
itht(not_equal_to)(not_equal_to<>): this object's tt(operator()) member
|
|
calls ti(operator!=), passing the latter operator its two parameter values and
|
|
returning the latter operator's return value.
|
|
itht(greater)(greater<>): this object's tt(operator()) member calls
|
|
ti(operator>), passing the latter operator its two parameter values
|
|
and returning the latter operator's return value.
|
|
itht(greater_equal)(greater_equal<>): this object's tt(operator()) member
|
|
calls ti(operator>=), passing the latter operator its two parameter values and
|
|
returning the latter operator's return value.
|
|
itht(less)(less<>): this object's tt(operator()) member calls
|
|
ti(operator<), passing the latter operator its two parameter values and
|
|
returning the latter operator's return value.
|
|
itht(less_equal)(less_equal<>): this object's tt(operator()) member calls
|
|
ti(operator<=), passing the latter operator its two parameter values
|
|
and returning the latter operator's return value.
|
|
)
|
|
An example using the relational function objects in combination with
|
|
ti(sort) is:
|
|
verbinclude(stl/examples/sort.cc)
|
|
The example illustrates how strings may be alphabetically and reversed
|
|
alphabetically sorted. By passing tt(greater_equal<string>) the strings are
|
|
sorted in em(decreasing) order (the first word will be the 'greatest'), by
|
|
passing tt(less<string>) the strings are sorted in em(increasing) order (the
|
|
first word will be the 'smallest').
|
|
|
|
Note that tt(argv) contains tt(char *) values, and that the relational
|
|
function object expects a tt(string). The promotion from tt(char const *) to
|
|
tt(string) is silently performed.
|