Interconverting Std:Function with Copyable_function
The article discusses the interconversion between std::function and the newly introduced std::copyable_function in C++26, highlighting design differences and performance implications. It explains how repeated conversions can create a linked‑list‑like chain of callables that degrades call‑operator speed. The author notes that, as of July 2026, only libstdc++ implements copyable_function and exhibits the described suboptimal behavior.
- ▪C++26 adds std::copyable_function to address shortcomings of std::function, while retaining some of its design quirks.
- ▪Converting between std::function and copyable_function can cause O(1) constructions but may build a chain of wrappers that slows invocation after many rounds.
- ▪The conversion from move_only_function to copyable_function is prohibited because copyable_function requires copyable callables.
- ▪libstdc++ is currently the only major STL implementation that supports copyable_function, and its implementation follows the less efficient conversion pattern described.
Hacker News (Newest) files mainly under programming. We currently carry 5,306 of its stories.
Story provenance
Source · retrieval · rights · ranking — open for full record
inspect →
Attribution is not the same as permission. This drawer separates discovery metadata, excerpts, WeSearch-generated summaries, reuse status, and whether the publisher receives the visit. Nothing here claims a legal grant the publisher has not made.
Record
| Original publisher | Arthur O’Dwyer |
| Canonical URL | https://quuxplusone.github.io/blog/2026/07/26/function-explosion/ |
| Publication time | Mon, 27 Jul 2026 05:39:33 +0000 |
| Retrieval time | 2026-07-27T05:57:39.433Z |
| Last seen | 2026-07-27T05:57:39.433Z |
| Headline source | Publisher (no WeSearch rewrite) |
| Excerpt source | publisher body |
| Excerpt method | First ~120 words (~800 chars) of extracted publisher body, fair-use limited. |
| Summary | WeSearch · cerebras-chat (WeSearch summarizer) |
| Summary source text | contentText |
| Citation coverage | Summary is a WeSearch-generated derivative; primary citation is the original publisher URL. |
| Cluster | nQEJ_pqdeIlh · 1 stories |
| Cluster logic | Grouped by semantic title/content similarity across sources within a rolling window. Same-publisher template collisions are excluded from coverage comparison. |
| Ranking reason | Story pages are not engagement-ranked. Hub feeds use recency, with optional source-diversified chronological ordering (cap consecutive stories per source). No personalized ranking. |
| Publisher visit | Yes — open original |
| Substitutes article? | No — link-out required for full text |
Rights status (four layers)
WeSearch handling by dimension
| Indexing | May the item be indexed (stored, ranked, made findable)? | Allowed |
| Snippet | May a short excerpt of the publisher's text be shown? | Allowed |
| AI summary | May WeSearch generate its own short summary of the article? | Limited |
| Retrieval / RAG | May the content be exposed for third-party retrieval-augmented generation? | Not asserted |
| Model training | May the content be used to train AI models? | Not asserted |
| Commercial reuse | May the content be reused commercially? | Not permitted |
Basis: Derived from the published RSS/Atom feed. Contact: [email protected]. Reviewed: 2026-07-24.
Opening excerpt (first ~120 words) tap to expand
Interconverting std::function with copyable_function C++11 introduced std::function as a type-erased callable-object holder. function was badly designed in a few ways: Its rarely used “go fish” API bloats every user; it advertises operator() const even when the controlled object’s operator() is mutating; it handles what should be a precondition violation by throwing an exception, which again bloats every user and means its operator() can never be noexcept. So C++26 fixed these problems by adding std::copyable_function.
…
Excerpt limited to ~120 words for fair-use compliance. The full article is at Arthur O’Dwyer.