~/talk

Save Time, Space & a Little Sanity With std::function_ref

Talkat CppNorth 2024 Β· 2024-07-21..07-24
links:none on file
slides:none on file

std::function_ref is a non-owning type-erased reference for C++26 callables that stores a callable as a pair of pointers (two pointers), is trivially copyable, avoids allocations and RTTI, and trades ownership for speed and smaller binaries. Benchmarks compile and link generated code up to up to 3,000 callables and show huge code-size and compile-time expansion without type erasure, while function_ref keeps code size nearly flat and often improves runtime versus std::function. Watch for dangling references (string_view-style lifetimes), the non-type template parameter for member pointers, and the thunk + bound-entity implementation details.

AI-written summary Β· about

  1. 0:00Introduction
  2. 0:22Overview
  3. 1:28What is it
  4. 4:03Callables
  5. 6:12How to use
  6. 8:44Dont use it
  7. 12:58How does it work
  8. 18:50Why use it
  9. 20:49Calculator
  10. 28:39Scaling
  11. 28:53Benchmarking
  12. 34:09Slides
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark β€” the status bar button does the same
?
this help
esc
close this, then clear every filter β€” or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.