Universal/Forwarding References
summary
Concrete rules and gotchas about T&&, auto&& and std::forward determine whether code moves, copies or fails to compile: template-parameter rvalue references become universal (forwarding) references with special deduction and reference-collapsing rules; using them plus forwarding yields perfect forwarding while preserving value category; range-based for and C++20 views require universal references to avoid adding const; decltype(auto) and lifetime-extension details show when returns must be by value or reference.
AI-written summary · about
chapters (18)
- 0:00Universal forwarding references intro
- 2:08Lifetime extension of temporaries
- 4:13Auto & ampersand with universals
- 7:24History of C++ value categories
- 13:46Lvalues xvalues prvalues explained
- 18:05Rvalue references and move semantics
- 25:52Perfect forwarding in templates
- 30:05Universal vs forwarding debate
- 34:09Universal reference rules
- 38:52Auto && as universal reference
- 42:14Range-based loops and universals
- 45:08Specifying types for universals
- 47:18Generic rvalue references
- 50:09Returning values with auto decltype
- 53:21Views and const correctness
- 55:51Universals as default type
- 57:17Teaching universal references
- 58:40Q&A
related talks
01h 02mBack to Basics: Forwarding References - How to Forward Parameters in Modern C++
01h 03mBack to Basics: Declarations in C++
07mOn parameter sinks
01h 10mType Deduction and Why You Care
54mA Tour of C++ Recognised User Type Categories
01h 04mC++ Concepts
01h 01mBack to Basics: Concepts in C++
01h 11mC++20 Templates: The next level: Concepts and more
