From Jason Turner
Watch on YouTube

Summary

This episode explores the often-overlooked capability of converting non-capturing lambdas to function pointers in C++. Jason demonstrates how this conversion can simplify code in certain scenarios, particularly when using lambdas as comparators or when storing collections of function-like objects. Through compiler explorer examples, he highlights the significant difference in generated code size and potential performance benefits when using simple function pointers instead of the more heavyweight std::function for non-capturing lambdas.

Resources

Tags