Back To Basics: Lambda Expressions
summary
Covers concrete C++11→20 changes: capture semantics happen at lambda evaluation, so capturing int x by value prints the original value; move capture makes closure non-copyable so it cannot be stored in std::function; generalized captures let code move unique_ptrs into closures and rename captures; C++17 adds capturing this vs this semantics and C++20 adds template parameters, requires and deprecates default this by value; structured bindings become capturable in C++20 with a portable workaround structured binding capture workaround 'x = x'*
AI-written summary · about
chapters (31)
- 0:00Introduction to Lambda Expressions
- 1:12CopperSpice Project Overview
- 2:15Origin of Lambda Term
- 4:23Function Pointers Explained
- 6:52Function Objects and Functors
- 10:05Lambda Expression Structure
- 12:53Capture Clause Basics
- 17:08Capture by Value and Reference
- 20:39Generalized Capture in C++14
- 23:10Capturing this in Class Methods
- 25:43Default Capture and Global Variables
- 27:29Lambda Evaluation vs Invocation
- 28:52Captures and Function Pointers
- 29:35Parameter List and Return Type
- 31:45Specifying Return Types
- 32:07C++20 Lambda Enhancements
- 33:51constexpr and consteval Lambdas
- 34:56Exception Specifiers
- 35:42Function Attributes
- 36:47Requires Clause in Lambdas
- 37:52Why Lambda Expressions Matter
- 39:15Compiler-Generated Function Objects
- 41:00Lambda as Callback Example
- 43:49Capturing Non-Copyable Objects
- 47:19Storing Closures in Functions
- 48:28Lambda in std::map Comparison
- 50:15Generic Lambda Explained
- 52:02Structured Bindings Capture Issue
- 53:46Summary and Key Takeaways
- 54:28Q&A Session Part 1
- 57:41Q&A Session Part 2
related talks
49mC++17 Features (part 1 of 2)
59mLambdas from First Principles: A Whirlwind Tour of C++""
05mImmediately Invoked Coroutine Lambdas in C++23 - Lifetime Pitfalls & Best Practices
50mExpression Templates: Past, Present, Future
01h 00mC++17, part 1: The Language Features
01h 27mC++20 Templates - the Next Level: Concepts and More
01h 21mWhat Has C++20 Ever Done For Templates?
01h 00mConcepts in C++20: Revolution or Evolution
