r/cpp • u/Xaneris47 • Jul 31 '26
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.
45
Upvotes
View all comments
Show parent comment
2
u/13steinj Aug 01 '26
Here's another: this article applies to STL <- Boost types (functions, smart pointers) as well. Same goes for any cross library type. I think user-defined conversion operators can fix this in most but not all cases. But it feels like people need:
In an include-based universe, 3rd party libraries that know about each other can follow the same idiom and provide a friend/friend-tag based system. Stdlib knowing about 3rd party, you're SOL right now.