This book is an adapted version, made for Embarcadero’s C++ Builder.
This book shows the story of lambda expressions in C++. You’ll learn how to use this powerful feature in a step-by-step manner, slowly digesting the new capabilities and enhancements that come with each revision of the C++ Standard.
We’ll start with C++98/03, and then we’ll move on to the latest C++ Standards.
- C++98/03 – how to code without lambda support. What was the motivation for the new
modern C++ feature?
- C++11 – early days. You’ll learn about all the elements of a lambda expression and even
some tricks. This is the longest chapter as we need to cover a lot.
- C++14 – updates. Once lambdas were adopted, we saw some options to improve them.
- C++17 – more improvements, especially by handling this pointer and allowing
Additionally, you’ll find techniques and handy patterns throughout the chapters for using lambda in your code. Walking through the evolution of this powerful C++ feature allows us not only to learn lambdas but also to see how C++ has changed over recent years. In one section you’ll see a technique and then it will be “iterated” and updated in further chapters when new C++ elements are available. When possible, the book cross-links to other related sections of the book.
- Callable Objects in C++98/03
- What is a “Functor”?
- Issues with Function Object Class Types
- Composing With Functional Helpers
- The Syntax of Lambda Expression
- A Few Examples of Lambda Expressions
- Core Definitions
- Compiler Expansion
- The Type of a Lambda Expression
- Constructors and Copying
- The Call Operator
- Other Modifiers
- Generated Code
- Capture All or Explicit?
- Invocation Counter – An Example of Captured Variables
- Capturing Global Variables
- Capturing Statics
- Capturing a Class Member And the
- Moveable-only Objects
- Preserving Const
- Capturing a Parameter Pack
- Return Type
- Trailing Return Type Syntax
- Conversion to a Function Pointer
- A Tricky Case
- IIFE – Immediately Invoked Functional Expression
- Inheriting from a Lambda
- Default Parameters for Lambdas
- Return Type Deduction
- Captures With an Initialiser
- Capturing a Class Data Member
- Generic Lambdas
- Variadic Generic Arguments
- Perfect Forwarding with Generic Lambdas
- Deducing the Correct Type
- Exception Specification in the Type System
- Capturing Variables
- Capture of
- Updates To IIFE
- Updates to Variadic Generic Lambdas
- Deriving from Multiple Lambdas
- Custom Template Argument Deduction Rules
- Extension to Aggregate Initialisation
Read Buy Print Edition (paid link)
As an Amazon Associate I earn from qualifying purchases made through Amazon links appearing on this website.