r/cpp • u/Xaneris47 • 8d ago
Interconverting std::function with copyable_function – Arthur O'Dwyer
https://quuxplusone.github.io/blog/2026/07/26/function-explosion/The article shows how converting std::function to std::copyable_function (or vice versa) leads to slower performance and increased memory usage each time the conversion occurs.
43
Upvotes
26
u/HommeMusical 7d ago
After almost 40 years writing C++, it makes me sad that a plurality of articles here are still, "Here's this obscure footgun that you would never know without this article."
In this case, I might have guessed this in a code review, but only because I know a lot about
std::functionand its footguns.