Klaus Iglberger delivers part two of a C++ training session on move semantics, focusing on forwarding references, perfect forwarding, and associated pitfalls. He explains how forwarding references adapt to L-values and R-values, detailing the concept of reference collapsing and its importance in perfect forwarding. The lecture explores how forwarding references solve the problem of forwarding arguments to other functions, like constructors, and introduces `std::forward` as a conditional move. Iglberger then discusses the perils of overloading with forwarding references, using examples to illustrate unexpected behaviors and offering advice to avoid common mistakes, including issues related to copy elision and incorrect usage in templates. The session concludes with a Q&A segment addressing stack frame behavior, return value optimization, and other related concerns.
Sign in to continue reading, translating and more.
Continue