
Source code
This lecture explains function pointers, static binding vs. dynamic binding, and how to obtain and use function addresses; it covers pointer syntax, signature matching, implicit calls, and runtime function switching.
Explore how callbacks implement event handling and asynchronous execution using function pointers in C++, enabling inversion of control with the dependency inversion principle, plus plugin-like customization and loose coupling.
Compare function objects with functions to show state, parameterization, and compile-time binding. Discuss function pointers versus objects, covering serialization, type safety, inlining, and code size impacts on callbacks.
Explore converting function pointers to function objects and using lambda expressions to replace boilerplate, enable type conversion operators for stateful functors, and work with invoke in C++.
Explore lambda expressions in C++11 as concise function objects. Let the compiler generate an anonymous class with an overloaded operator(), capturing surrounding variables as a closure.
Explore the capture list in C++ lambda expressions, including capturing by value or reference, pack captures, and this pointer, plus stateful versus stateless lambdas with trailing return type.
explore how lambda expressions implement an immediately invoked function expression to create a private scope, prevent global namespace pollution, and perform one-time logic for initialization and constant setup.
Demonstrate rendering support links using a support type enum and a get support type function to show WhatsApp during working hours and email otherwise, with HTML rendering and constant considerations.
Explore generic lambdas in c++14, where auto parameter types let lambdas act like function templates, boosting flexibility and reusability for algorithms on containers.
Demonstrates capturing by constant reference in lambdas with as const in c++17, applying the const qualifier to captured references and preventing modification, while discussing limitations with move-only types.
Examine lambda improvements in C++20, focusing on implicit capture of this, its deprecation with default capture, and the need to explicitly capture this to prevent undefined behavior.
Learn how consteval enables lambda expressions to be immediate functions that always execute at compile time, unlike constexpr lambdas, and understand capture expressions and the requirement for compile-time expressions.
Template type parameters in lambda expressions, introduced in c++20, let lambdas behave like function templates, work with argument and element types, and forward arguments for more powerful, reusable code.
Explore the challenge of creating recursive lambdas in c++, showing how std::function and passing self enable recursion, compare with function objects, and note c++23's upcoming simplification.
Unlock the full power of callable objects in C++ with this comprehensive journey from traditional C-style callbacks to the very latest C++23 lambda expressions. This course is designed for professional developers who want to move beyond syntax and gain a true, deep understanding of how to write expressive, modern, and highly efficient C++ code.
Start by building a solid foundation with function pointers, exploring the classic C-style approach to callbacks to understand the problems that modern C++ aimed to solve. From there, you will take a deep dive into function objects (functors), learning how to build powerful, stateful operations by creating classes that behave like functions.
Finally, you will progress to lambda expressions. We explore their complete evolution, from the fundamentals in C++11 to the advanced generic and templated features in C++14, C++17, and C++20, all the way to the cutting-edge additions in C++23. By understanding their origins in function pointers and functors, you will see exactly why lambdas are one of the most elegant and powerful features in modern C++.
Whether you're looking to modernize your codebase, master STL algorithms, or simply write cleaner code, this course will give you a complete and confident command of C++'s callable machinery.