Use function objects judiciously: For very simple loops, handwritten loops can be the simplest and most efficient solution. But writing algorithm calls instead of handwritten loops can be more expressive and maintainable, less error-prone, and as efficient.
When calling algorithms, consider writing your own custom function object that encapsulates the logic you need. Avoid cobbling together parameter-binders and simple function objects (e.g.,
plus), which usually degrade clarity. Consider trying the [Boost] Lambda library, which automates the task of writing function objects.
Programs that use the STL tend to have fewer explicit loops than non-STL programs, replacing ...