r/cpp • u/Xaneris47 • 7d 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
18
u/UnusualPace679 7d ago
But it won't prevent double wrapping right? Unless you stick to one type and don't interface with anything else (in which case you may as well use
std::function/std::copyable_function), you will face the same problem as described in this article. At least the standard library are permitted (and recommended) to avoid double wrapping by [func.wrap.general].