7

The Complete Guide to `return x;` - Arthur O'Dwyer - [CppNow 2021]

 2 years ago
source link: https://www.youtube.com/watch?v=OGKAJD7bmr8
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
#Boost​ #Cpp​ #CppNow​

The Complete Guide to `return x;` - Arthur O'Dwyer - [CppNow 2021]

1,678 views
Premiered Jul 3, 2021

18.5K subscribers

#Boost​ #Cpp​ #CppNow​ Slides: https://cppnow.org/history/2021/talks/ CppNow Website: https://cppnow.org​ CppNow Twitter: @CppNow Streamed & Edited By Digital Medium Ltd: https://events.digital-medium.co.uk​ ------ Join Arthur O'Dwyer on a deep dive into Return Value Optimization, implicit move, and related topics. We'll start with an explanation of the calling convention on a typical machine, showing where the mysterious "return slot" lives, and why it makes sense that C++03 allowed copy elision in certain special cases (but not others). Then we'll show how C++11 (and a subsequent defect report) upped the game by quietly turning the remaining copies into moves, so that the received wisdom these days is that `return std::move(x)` is never necessary and often a pessimization (because it disables RVO). However, even in C++17, `return x` would sometimes quietly copy a large object instead of moving it. C++20 adopted Arthur's P1155 "More Implicit Moves," which means that many of these cases have been fixed. Arthur will show one or two cases that remain troublesome. Furthermore, C++20 adopted David Stone's P0527 "Implicitly move from rvalue references." This paper is a core-language game-changer: it permits `return x` to move out of the target of `x` when `x` is an rvalue reference. We'll show how this surprising new feature of C++20 can be used in the "perfect returning idiom." ...Or can it? We'll review various late-breaking issues surrounding implicit move and the solutions proposed in Arthur's P2266 "Simpler Implicit Move." ------ Arthur O'Dwyer

Arthur O'Dwyer is the author of "Mastering the C++17 STL" (Packt 2017) and of professional training courses such as "Intro to C++," "Classic STL: Algorithms, Containers, Iterators," and "The STL From Scratch." (Ask me about training your new hires!) Arthur is occasionally active on the C++ Standards Committee and has a blog mostly about C++. He is also the author of "Colossal Cave: The Board Game," an avid club juggler, and the recipient of four ------ CppNow 2021: May 1, 2022 - May 6, 2022 - Aspen, Colorado -------------------------

Show lessShow more


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK