Let T
be an arbitrary type. Consider a function that takes a const
[lvalue] reference:
void f(const T &obj);
Suppose that this function internally makes a call to another function, which has an rvalue reference overload:
void g(T &&obj);
If we pass an rvalue to f
, will the rvalue reference overload of g
be called, or will it fail to do so since it has been "converted"/bound to a const
lvalue reference?
Similarly, if f
called a function that takes an instance of T
by value,
void h(T obj);
and T
has a move constructor, (i.e. T(T &&);
), will the move constructor be called, or will the copy constructor be called?
In conclusion, if we wanted to ensure that, when calling f
on an rvalue, the rvalue reference is passed around keeping its rvalue "status", would we necessarily have to provide an rvalue reference overload for f
?