C++ Lambda Story
C++ Lambda Story
Minimum price
Suggested price
C++ Lambda Story

Last updated on 2019-04-04

About the Book

This short book shows the story of lambda expressions. We'll start with C++03 and a motivation to have "ad-hoc" functors, and then we'll move into the latest C++ standards:

  • 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 of topics.
  • 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 `constexpr`.
  • C++20 - in this section we'll have a glimpse overview of the future.

The book contains updated versions of two articles that appeared at bfilipek.com:

I added more examples and better descriptions to describe lambdas in a better way!

The articles also are based on a live coding presentation given by C++ Expert Tomasz Kamiński at our local Cracow C++ User Group.

About the Author

Bartłomiej Filipek
Bartłomiej Filipek

Bartłomiej Filipek is a C++ software developer with more than 11 years of professional experience, MVP and C++ ISO Member. In 2010 he graduated from Jagiellonian University in Cracow with a Masters Degree in Computer Science.

Bartek currently works at Xara, where he develops features for advanced document editors. He also has experience with desktop graphics applications, game development, large-scale systems for aviation, writing graphics drivers and even biofeedback. In the past, Bartek has also taught programming (mostly game and graphics programming courses) at local universities in Cracow.

Since 2011 Bartek has been regularly blogging at his personal website: bfilipek.com. In the early days the topic revolved around graphics programming, and now he focuses on Core C++. He's also a co-organizer of C++ User Group in Cracow.

Since October 2018, Bartek has been a C++ Expert for Polish National Body that works directly with ISO/IEC JTC 1/SC 22 (C++ Standard Committee).

In the same month, Bartek was also awarded by Microsoft and got his first MVP title for years 2019/2020 in the area of Developer Technologies.

In his spare time, he loves assembling trains and Lego with his little son. And he’s a collector of large Lego models.

Table of Contents

  • About the Book
    • Who This Book is For
    • Reader Feedback
  • About the Author
  • Acknowledgement
  • Revision History
  • 1. Lambdas in C++03
    • Issues
    • Motivation for a New Feature
  • 2. Lambdas in C++11
    • The Syntax
    • The Type of a Lambda
    • The Call Operator
    • Captures
    • Return Type
    • IIFE - Immediately Invoked Function Expression
    • Conversion to a Function Pointer
    • Summary
  • 3. Lambdas in C++14
    • Default Parameters for Lambdas
    • Return Type
    • Captures With an Initializer
    • Capturing a Member Variable
    • Generic Lambdas
    • Bonus - LIFTing with lambdas
    • Summary
  • 4. Lambdas in C++17
    • constexpr Lambda Expressions
    • Capture of *this
    • Summary
  • 5. Future with C++20
    • Quick Overview of the Changes
    • Template Lambdas
    • Summary
  • References
  • Notes

The Leanpub 45-day 100% Happiness Guarantee

Within 45 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms

Free Updates. Free App. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers), EPUB (for phones and tablets), MOBI (for Kindle) and in the free Leanpub App (for Mac, Windows, iOS and Android). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

Authors, publishers and universities use Leanpub to publish amazing in-progress and completed books and courses, just like this one. You can use Leanpub to write, publish and sell your book or course as well! Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks. Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. It really is that easy.

Learn more about writing on Leanpub