Oleg Zabluda's blog
Thursday, January 19, 2017
 
C++ Rvalue References Explained
C++ Rvalue References Explained
"""
Introduction
Move Semantics
Rvalue References
Forcing Move Semantics
Is an Rvalue Reference an Rvalue?
Move Semantics and Compiler Optimizations
Perfect Forwarding: The Problem
Perfect Forwarding: The Solution
Rvalue References and Exceptions
The Case of the Implicit Move
Acknowledgments and Further Reading
[...]
Rvalue references solve at least two problems:

Implementing move semantics
Perfect forwarding
[...]
1.
void foo(X& x); // lvalue reference overload
void foo(X&& x); // rvalue reference overload
[...]
The primary (and for all practical purposes, the only) application of that is to overload the copy constructor and copy assignment operator of a class for the sake of implementing move semantics. [...] pay attention to exception handling, and use the new noexcept keyword as much as you can.

2. std::move turns its argument into an rvalue.

3. std::forward allows you to achieve perfect forwarding if you use it exactly as shown in the factory function example in Section 8.
"""
http://thbecker.net/articles/rvalue_references/section_01.html
http://thbecker.net/articles/rvalue_references/section_01.html

Labels:


| |

Home

Powered by Blogger