Class Central is learner-supported. When you buy through links on our site, we may earn an affiliate commission.

YouTube

The C++ Rvalue Lifetime Disaster - Understanding and Mitigating Issues

cpponsea via YouTube

Overview

Explore the intricacies of C++ rvalue lifetimes in this conference talk from C++ on Sea 2023. Delve into the challenges and potential pitfalls of rvalue references, including their impact on memory management and code safety. Learn about the unexpected behavior of rvalues binding to const& and the limitations of temporary lifetime extension. Discover a library-only approach to mitigate these issues and consider a proposal for potential language improvements. Gain insights from real-world examples of memory corruption caused by these problems and understand their implications for generic code and the C++ standard library.

Syllabus

Introduction
Rvalue Lifetime
Named Return Value Optimization
No Named Return Value Optimization
A Special Case
Recommendations
Temporary Lifetime Extension
Generic Code
Lifetime Extension
Example
The problem
The solution
Declaration type
Autocrf
Autocrf const
Autocrf rvalue
Accessors
C
What C does
We made a mess
Warning
Requirements
Reference Binding
Trying it out
Impact on the standard library
Mitigations
Member Accessors
Conclusion

Taught by

cpponsea

Reviews

Start your review of The C++ Rvalue Lifetime Disaster - Understanding and Mitigating Issues

Never Stop Learning.

Get personalized course recommendations, track subjects and courses with reminders, and more.

Someone learning on their laptop while sitting on the floor.