
—
Presentation Slides, PDFs, Source Code and other presenter materials are available at: https://github.com/CppCon/CppCon2018
—
Join Arthur O'Dwyer on a deep dive into Return Value Optimization and related topics.
Even C++03 allowed the compiler to "elide" copy construction in certain cases. 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 commonly received wisdom these days is that `return std::move(x)` is never necessary and often a pessimization.
...Or is it? We'll show some real-world examples where `return x` quietly copies a large object instead of moving it. We'll explain the little-known notion of a "converting constructor", contrast it with "conversion operator", and show the precise way in which C++17 drops the ball on these examples. Finally, Arthur implemented a Clang compiler warning to detect and suggest fixes for problematic return statements; he'll walk through the relatively painless process of creating that diagnostic, and perhaps inspire you to contribute to Clang yourself!
—
Arthur O'Dwyer
Arthur O'Dwyer started his career writing pre-C++11 compilers for Green Hills Software; he currently writes C++14 for Akamai Technologies. Arthur is the author of "Colossal Cave: The Board Game," "Mastering the C++17 STL" (the book), and "The STL From Scratch" (the training course). He is occasionally active on the C++ Standards Committee and has a blog mostly about C++.
—
Videos Filmed & Edited by Bash Films: http://www.BashFilms.com
c thomas howell CppCon 2018: Arthur O'Dwyer “Return Value Optimization: Harder Than It Looks” | |
188 Likes | 188 Dislikes |
8,194 views views | 63.8K followers |
Education | Upload TimePublished on 2 Nov 2018 |
Related keywords
c train schedule,c diff,c section,c corporation,c town,c train service,c section scar,c to k,c battery,c span,c train,c street,c suite,c to f,c stock,c reactive protein,c elegans,c chord guitar,c train status,
Không có nhận xét nào:
Đăng nhận xét