September 2017
Intermediate to advanced
822 pages
26h 51m
English
Since the beginning, C++ has provided call-by-value and call-by-reference, and it is not always easy to decide which one to choose: Usually calling by reference is cheaper for nontrivial objects but more complicated. C++11 added move semantics to the mix, which means that we now have different ways to pass by reference:1
1. X const& (constant lvalue reference):
The parameter refers to the passed object, without the ability to modify it.
2. X& (nonconstant lvalue reference):
The parameter refers to the passed object, with the ability to modify it.
3. X&& (rvalue reference):
The parameter refers to the passed object, with move semantics, meaning that you can modify or “steal” the value.
Deciding how to declare ...
Read now
Unlock full access