We know that in this code...
Beta_ab const& getAB() const { return ab; }
^^^^^
The highlighted const
means that the member function may be called upon a const
object. A member function can always be called upon a non-const
object regardless of the function's cv-qualification.
So in this code...
Beta_ab const& getAB() const & { return ab; }
^
We should expect that the highlighted &
also says something about what kinds of objects this member function is allowed to be called upon. We would be correct; in C++11, this says that the member function may only be called upon lvalues.
Beta_ab const& getAB() const& { return ab; }
Beta_ab && getAB() && { return ab; }
In the above example, the first overload is invoked on lvalues, and the second overload is invoked on non-const
rvalues. Similar to the following more familiar example, with qualifiers applied to ordinary function parameters:
void setAB(AB const& _ab) { ab = _ab; }
void setAB(AB && _ab) { ab = std::move(_ab); }
It works slightly differently for ordinary parameters though, as in this example, the first overload would accept an rvalue if the second overload were removed.