Higher-order functions and function_ref
summary
Proposal claims a lightweight, non-owning callable view that sits between templates and std::function and lands in LWG for C++20 consideration; implementation uses a simple type-erasure of a void pointer plus an invoke function pointer; production uses include consume_if, replaying command queues and packet/node callbacks; benchmarks (quick-bench, Simon Brand’s impl) show std::function ≈7× slower than function_ref when inlined while function_ref matches template performance when inlined; caveat: dangling-reference risk.
AI-written summary · about
chapters (39)
- 0:00Introduction
- 0:45YouTube channel
- 0:57Open source projects
- 1:14Outline
- 1:38Disclaimer
- 2:14Assumptions
- 2:26Higherorder functions
- 5:18Signal
- 6:34lambda expressions
- 7:56arrays remove
- 10:53variant
- 12:12use cases
- 12:29avoid repetition
- 13:49example
- 15:52local lambda
- 17:06execution policy
- 18:33unit testing
- 19:04abstraction
- 19:49structure
- 20:17for separated
- 21:51print
- 23:18consumeif
- 26:22Synchronicity
- 30:08Test drivers
- 31:51Higherorder functions vs other obstructions
- 32:14Threadsafe access wrapper
- 33:38Synchronized instance
- 35:37Implementation
- 37:28Benchmarking
- 37:55Iterators
- 42:11Recap
- 43:57Second half
- 44:19Function pointers
- 47:05Template parameters
- 48:27City functions
- 50:39Functionref
- 52:28Why use functionref
- 53:51Interface
- 54:26Examples
related talks
01h 01mHigher-order functions in Modern C++: existing techniques and function_ref
31m“folly::Function: A Non-copyable Alternative to std::function”
37mC++ Zero Overhead Pass by Value Through Invocable C++ Abstractions
49mBack to Basics: Type Erasure
01h 00mC++ Function Templates: How Do They Really Work?
01h 02mFunctional C++
32mWhy and How to Roll Your Own std::function Implementation
01h 03mHigher order functions for ordinary C++ developers
