There's a simple rule: If the conditions for copy elision are met (except that the variable may be function parameter), treat as rvalue. If that fails, treat as lvalue. Otherwise, treat as lvalue.
§12.8 [class.copy] p32
When the criteria for elision of a copy operation are met or would be met save for the fact that the source object is a function parameter, and the object to be copied is designated by an lvalue, overload resolution to select the constructor for the copy is first performed as if the object were designated by an rvalue. If overload resolution fails, or if the type of the first parameter of the selected constructor is not an rvalue reference to the object’s type (possibly cv-qualified), overload resolution is performed again, considering the object as an lvalue. [ Note: This two-stage overload resolution must be performed regardless of whether copy elision will occur. It determines the constructor to be called if elision is not performed, and the selected constructor must be accessible even if the call is elided. —end note ]
Example:
template<class T>
T f(T v, bool b){
T t;
if(b)
return t; // automatic move
return v; // automatic move, even though it's a parameter
}
Not that I personally agree with that rule, since there is no automatic move in the following code:
template<class T>
struct X{
T v;
};
template<class T>
T f(){
X<T> x;
return x.v; // no automatic move, needs 'std::move'
}
See also this question of mine.