Chapter 6. Functors, Functor Classes, Functions, etc

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., for_each and transform) are meaningless without them, and adapters like not1 and 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 ...

Get Effective STL now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.