July 29, 2026
Callback chaos goes full nesting-doll
Interconverting std::function with copyable_function
C++ fans are side-eyeing a “fixed” feature that may secretly make code slower
TLDR: C++26 adds `copyable_function` to clean up problems with the old `std::function`, but mixing the two can create a chain of nested wrappers that may hurt performance. Commenters are split between “this is embarrassing design” and “this only happens in messy half-upgraded codebases,” with plenty of jokes about callback inception.
A fresh C++26 upgrade was supposed to be the cleanup arc for one of the language’s most infamous old tools: std::function, the little box programmers use to store “something callable.” Instead, the reaction from the community is basically: wait, did we just add a new box that still has old baggage and can even create weird slow-motion nesting dolls when mixed with the old one? The article explains that the shiny replacement, std::copyable_function, fixes some long-criticized design choices. But the real comment-section energy is all about what happens when teams use both old and new code together and accidentally stack wrappers inside wrappers inside wrappers.
That possibility lit up the peanut gallery. One camp is furious that a “modern fix” still leaves room for clunky behavior, with commenters joking that C++ can never retire a feature without introducing a sequel, a reboot, and a confusing crossover episode. Another camp is more forgiving, arguing this is a niche edge case and blaming half-upgraded codebases, not the new tool itself. The funniest reactions compared the bad implementation to a Russian doll of callbacks, a forwarded phone call that keeps getting re-forwarded, and “the programming equivalent of putting your leftovers in three containers and forgetting what’s inside.” The spiciest drama? Some people see this as proof that C++ standard library design moves too cautiously; others say library vendors, not the language, are the ones dropping the ball. Either way, the crowd agrees on one thing: if a “move” quietly turns into a chain of boxes calling boxes, someone’s going to end up rage-benchmarking.
Key Points
- •The article says C++26 introduced `std::copyable_function` to address several design problems associated with C++11’s `std::function`.
- •It cites P2548 as recommending that implementations avoid extra allocations when converting from `copyable_function` to compatible `move_only_function`, while leaving that as quality-of-implementation.
- •The article states that `std::copyable_function` and `std::function` are interconvertible in both directions because both can hold copyable callables and are themselves copyable and callable.
- •If implementations do not optimize these conversions, repeated moves between the two wrappers can create nested layers of wrapped callables, increasing invocation depth.
- •According to the article, as of July 2026 libstdc++ is the only Big Three STL implementation with `copyable_function`, and it currently shows the nested-wrapper behavior described.