O'Reilly logo

The C++ Standard Library: A Tutorial and Reference, Second Edition by Nicolai M. Josuttis

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required