Chapter Overview

Get an idea of what we'll cover in this chapter.

We'll cover the following...

A literal expression is a representation of a value in code that is written directly as it appears in the program, rather than being computed or evaluated.Lambda expressions allow us to write good, clean generic code. They allow the use of functional programmingFunctional programming is a programming paradigm that emphasizes the use of pure functions and immutable data to avoid side effects and promote declarative programming. patterns, where we can use lambdas as functional parameters to algorithms and even other lambdas.

In this chapter, we will cover the use of lambdas with the STL, in the following recipes:

  • Use lambdas for scoped reusable code
  • Use lambdas as predicates with the algorithm library
  • Use std::function as a polymorphic wrapper
  • Concatenate lambdas with recursion
  • Combine predicates with logical conjunction
  • Call multiple lambdas with the same input
  • Use mapped lambdas for a jump table