Those templates can be used whenever someone expects a binary predicate, i.e. a free function taking two parameters. An overloaded operator<
may not be defined as a free, binary function, so these templates serve as a sort of adapter to let you use existing operators no matter how they were defined, as long as the expression a < b
can be resolved.
Note that the standard already provides very similar* templates; they're called std::less
and std::greater
, and they're used for example by the ordered, associative containers.
*) The standard library predicates provide additional guarantees on how they work on pointers.