~/talk

Universal/Forwarding References - A Key to More Modern C++

Talkat C++ on Sea 2022 · 2022-07-05..07-07· [compilers-and-language-design]
slides:none on file

Universal (template T&&) references enable one-template-parameter perfect forwarding via std::forward and reference-collapsing rules, and C++20 makes them essential for writing generic functions that accept both containers and views. Examples: implementing a call-through that forwards to foo, the range-based for expansion that uses an auto&& local to avoid copying or forcing const, and fixing view failures (drop/filter) that break when parameters are const. Use decltype(auto) to preserve returned value categories; using universal references resolves these issues.

AI-written summary · about

  1. 0:00Modern C++ introduction
  2. 1:12C++ references basics
  3. 2:16Move semantics and rvalues
  4. 5:48Value categories in C++
  5. 9:17xvalues evolution
  6. 13:56How compilers handle values
  7. 16:03Rvalue reference problems
  8. 18:55Functions with rvalue refs
  9. 22:28Call-by-reference comparison
  10. 27:03Universal references core
  11. 31:20Universal vs forwarding
  12. 34:12Universal ref rules
  13. 36:40Benefits of universal refs
  14. 38:27Specifying universal refs
  15. 42:59Common universal ref mistakes
  16. 45:28Generic non-member functions
  17. 49:02Perfect forwarding
  18. 51:07decltype(auto) returns
  19. 56:48C++20 universal refs
  20. 57:51Range-based loops
  21. 1:02:22Practical universal refs
  22. 1:07:15C++20 ranges challenges
  23. 1:12:33Why const lvalue fails
  24. 1:19:57Solutions for views
  25. 1:22:03Summary and future
  26. 1:26:26Q&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.