Chapter 2

Working with Lambda Expressions

IN THIS CHAPTER

check Defining why you need lambda expressions

check Understanding the parts of a lambda expression

check Performing practical tasks with lambda expressions

The “Using Lambda Expressions for Implementation” section of Chapter 1 of this minibook offers a brief overview of lambda expressions as they apply to transforms. However, lambda expressions can do considerably more than you discover in that section’s example. Using lambda expressions isn’t required to write good C++ code, but they can make your C++ code better and allow for certain optimizations in some cases. This chapter discusses in more detail how and when you use lambda expressions.

This chapter also describes the parts of a lambda expression. You may not ever use everything that a lambda expression has to offer, but it’s good to know what’s available. You might find that you can make your code even shorter and easier to understand by creating just the right type of lambda expression.

Finally, the chapter shows some examples of how to use lambda expressions for practical purposes such as sorting data. It also helps you understand some development nuances, such as throwing an exception ...

Get C++ All-in-One For Dummies, 4th Edition 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.