C++ Zero Overhead Pass by Value Through Invocable C++ Abstractions
summary
Library type erasure like std::function currently forces an extra copy/move when a non‑trivial object is passed by value; the claim is that this can be avoided. The technique rewrites the callee pointer types at runtime using a reinterpret_cast thunk that replaces non‑trivial value parameters with rvalue references (relying on the Itanium ABI calling convention), adds a constrained constructor and a match_signature overload resolution trick to pick the correct call operator, and yields a function_ref style abstraction that eliminates the extra copy/move on tested platforms (works but is formally undefined behavior).
AI-written summary · about
chapters (8)
- 0:00Introduction and motivation
- 2:30Passing values through abstractions
- 9:12Implementing function_ref
- 12:05Motivation and performance
- 17:50Constructors for free functions
- 18:12Member functions support
- 22:45Function objects and overloads
- 34:26Q&A and conclusion
related talks
49mBack to Basics: Type Erasure
01h 29mHigher-order functions and function_ref
48mTo Pass and Return — The Story of Functions, Values and Compilers
50mC++ Costless Abstractions: the compiler view
01h 03mC++ Trivial Relocation Through Time
31mCo- and Contra-: Adding a Little Variance
40munique_pseudofunction: N overloads for the price of 1
01h 00mC++ Function Templates: How Do They Really Work?
