Like it or not, functions and function-like objects—functors—pervade the STL. Associative containers use them to keep their elements in order, some algorithms (e.g.,
find_if) use them to control their behavior, others (e.g.,
transform) are meaningless without them, and adapters like
bind2nd actively produce them.
Yes, everywhere you look in the STL, you see functors and functor classes. Including in your source code. It’s not possible to make effective use of the STL without knowing how to write well-behaved functors. That being the case, most of this chapter is devoted to explaining how to make your functors behave the way the STL expects them to. One Item, however, is ...