Callbacks with std::function or templates?

Published: 03 June 2026
on channel: Code for yourself
1,816
105

📚 Code and script: https://github.com/cpp-for-yourself/s...

Help me keep doing these videos!
This works relies on your support! You can show it in one of these ways:
📺 Watch my videos to the end and leave comments
💶 Directly become a sponsor on GitHub: https://github.com/sponsors/niosus
▶️ Join this channel on YouTube:    / @codeforyourself  
📚 Start a FREE Audible trial: https://www.audibletrial.com/CodeForY...
⁉️ Find your way to support this work here: https://github.com/cpp-for-yourself/s...

What we cover
Using std::function gives us a generic and uniform way to store and pass around anything that behaves like a function. We also look at how similar things can be done with templates and explore how type erasure makes this work under the hood!

🔗 Links

CppReference pages
⏺ CppReference page on std::function: https://en.cppreference.com/w/cpp/uti...
⏺ CppReference page on Class Template Argument Deduction (CTAD): https://en.cppreference.com/w/cpp/lan...

#cplusplus #programming #coding #tutorial


On this page of the site you can watch the video online Callbacks with std::function or templates? with a duration of hours minute second in good quality, which was uploaded by the user Code for yourself 03 June 2026, share the link with friends and acquaintances, this video has already been watched 1,816 times on youtube and it was liked by 105 viewers. Enjoy your viewing!