Modern C++ Development: Limitations and Problems in std::function and Similar Constructs
summary
Claims that std::function, std::packaged_task and std::apply cause unexpected copies and moves and demonstrates them with an instrumented class that logs every copy/move. Measured counts show surprising churn (e.g. three moves for captured objects, two moves for by-value parameters, extra copies on bind and on some toolchains). Builds a concrete mitigation: a tuple-based holder plus a move wrapper and a templated function_holder that collapses copies to zero, cuts moves to the theoretical minimum and reduces heap allocations to one, with caveats about safety of the move wrapper.
AI-written summary · about
chapters (13)
- 0:00Welcome
- 1:50Adobe's cross-platform C++
- 5:24Lambdas and captures
- 10:39std::function overhead
- 16:24Unnecessary copies in std::function
- 24:31Optimal moves and copies
- 29:11std::function and shared_ptr
- 34:56Move wrapper to avoid shared_ptr
- 38:49Tuples for function parameters
- 48:01Conditional move and tuple logic
- 52:19Reducing boilerplate with traits
- 56:41Function holder solution
- 1:00:24Q&A
related talks
47mReducing Template Compilation Overhead, Using C++11, 14, 17, and 20.
01h 02mEveryday Efficiency: In-Place Construction (Back to Basics?)
01h 00mThe hidden rules of world-class C++ code
01h 11mPragmatic Simplicity - Actionable Guidelines To Tame Cpp Complexity
05mLightning Talk: find-move-candidates in Cpp
52mHigher Order Functions for ordinary developers
01h 01mTools from the C++ Ecosystem to save a leg
56mC++ Code Smells
