The Complete Guide to `return x;`


Details
https://www.twitch.tv/mucplusplus/
This month we have the honor to welcome Arthur O'Dwyer to our user group. Arthur O'Dwyer is the author of "Colossal Cave: The Board Game" and "Mastering the C++17 STL" (the book). He runs professional C++ training courses, is occasionally active on the C++ Standards Committee, and has a blog mostly about C++.
---------------------------
Abstract: Join Arthur O'Dwyer on a deep dive into Return Value Optimization, implicit move, and related topics. C++ has always been able to "elide" copy construction in certain cases. We'll start with an explanation of the "return slot" and show why 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. However, even in C++17, `return x` would sometimes quietly copy a large object instead of moving it. C++2a adopted Arthur's P1155 "More Implicit Moves," which means that many of these cases have been fixed. We'll see a few cases that remain troublesome. Furthermore, C++2a 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++2a can be used in the "perfect returning idiom." ...Or can it? We'll review various late-breaking issues surrounding implicit move and suggest resolutions for them.
---------------------------
Schedule:
19:00 (CEST) -- Start of the videostream


The Complete Guide to `return x;`