Chapter 10. STL Function Objects and Using Lambdas

This chapter discusses in detail the features to pass specific functionality to algorithms and member functions, function objects, or functors for short (introduced in Section 6.10, page 233). It covers the full set of predefined function objects and function adapters and binders and the concept of functional composition, provides examples of self-written function objects, and presents details about the application of lambdas (introduced in Section 3.1.10, page 28, and Section 6.9, page 229).

As a consequence, you will learn details and surprising behavior of the algorithms remove_if() and for_each().

10.1. The Concept of Function Objects

A function object, or functor, is an object that has operator ...

Get The C++ Standard Library: A Tutorial and Reference, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.