O'Reilly logo

Sams Teach Yourself C++ in One Hour a Day, Seventh Edition by Siddhartha Rao

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

Lesson 22. C++11 Lambda Expressions

Lambda expressions are a compact way to define and construct function objects without a name. These expressions are new to C++11. In this lesson, you find out

• How to program a lambda expression

• How to use lambda expressions as predicates

• How to program lambda expressions that can hold and manipulate a state

What Is a Lambda Expression?

A lambda expression can be visualized as a compact version of an unnamed struct (or class) with a public operator(). In that sense, a lambda expression is a function object like those in Lesson 21, “Understanding Function Objects.” Before jumping into analyzing the programming of lambda functions, take a function object from Listing 21.1 (from Lesson 21) as an example: ...

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