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.
Related C++ Standard Sections
This episode covers topics found in these sections of the C++ standard:
-
[locale.statics]63% match -
[locale.global.templates]60% match -
[expr.prim.this]49% match -
[class.local]49% match -
[alg.find]40% match