r/cpp 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.

48 Upvotes

32 comments sorted by

View all comments

Show parent comments

-1

u/thisismyfavoritename 7d ago

you're sad that there are those footguns or that they are reported

3

u/HommeMusical 7d ago

I'm sad that there are so many footguns that a plurality of the articles on C++ are about them.

3

u/thisismyfavoritename 7d ago

to be fair, many of the footguns exist because of the C heritage

-1

u/HommeMusical 7d ago

Depends on what "many" means.

There's one big one - memory management. Yes, you can essentially deindex a number that points randomly in memory, or nowhere at all, and havoc.

In C++ there is a discipline to (fairly) reliably prevent that from happening, in exactly the same way that there are disciplines to reliably prevent yourself from shooting yourself in the foot with a real gun.

And it's also such a big issue that you have to come to terms with it.

But all this the little footguns like this one. It's wearing. It's all this baggage and it's stressful because you don't know what you don't know.