From Jason Turner
Watch on YouTube

Summary

This episode explores the concept of local functions in C++ and explains why true local function definitions are not possible in the language. Jason demonstrates various workarounds that existed before C++11, including local classes with member functions and functor objects, while highlighting their limitations (especially in C++98 where local types couldn't be used as template arguments). The episode concludes by showing how lambdas, introduced in C++11, elegantly solve this problem by providing a concise syntax for creating local function-like objects.

Resources

Tags