~/talk

Back to Basics: Forwarding References - How to Forward Parameters in Modern C++

Talkat CppCon 2023 · on Friday, 2023-10-06· at 10:30· Maple 3/4/5, 6700 North Gaylord Rockies Boulevard· [typescript]
slides:none on file

Clear explanation of what a forwarding reference is, why std::forward preserves value category, and when the special deduction rule applies; shows real pitfalls: single-template constructors that hijack copy ctors and need remove_cvref<T> or constrained convertible_to checks, how to force move-only binding, and a coroutine-life-time trick (capture by value via forwarding). Concrete recommendations: prefer const T& for read-only, pass-by-value for cheap-to-move members, and constrain forwarding templates to avoid surprising overload resolution.

AI-written summary · about

  1. 0:00Introduction
  2. 2:27Value categories in C++
  3. 9:50Quiz on value categories
  4. 19:32C++11 rvalue references
  5. 26:11Forwarding references
  6. 33:58Perfect forwarding with std::forward
  7. 36:03Pitfalls with forwarding
  8. 43:05Copy constructor hijacking
  9. 47:02Restricting to rvalues
  10. 50:19Coroutines and arguments
  11. 52:50Returning parameters
  12. 55:22auto&& in generics
  13. 57:09Best practices
  14. 1:01:05Q&A
~/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.