I have created a comparator which defines "ascending" order for a custom class. This can be used with standard functions such as std::sort() and std::find(). Now what if I want to reverse the comparison to "descending" order? Is there a standard function object wrapper which will reverse the order of the arguments sent to my comparator object? Similarly, are there wrapper classes to create other comparisons (such as "equality") so I don't have to implement them manually?
Thanks, Cubbi. std::rel_ops has exactly what I had in mind. I think a using statement would bring it into the global namespace if I needed to wrap it in std::greater(). I doubt I need to go that far, though, since I'll just pass it as the Comp parameter to functions such as std::sort().
@Layne a namespace using won't help: greater will look in std and will find the ton of op>'s defined there, and will never think to search the global namespace. Sorry for bringing your hopes up.