If the function returned a reference (which it doesn't) then you might want to assign the return value to a reference in order to keep "up to date" with any changes to that object. The reference returned would have to be to an object with a lifetime that extended beyond the end of the function.
Or (if the returned reference was not-const
) because you wanted to keep a reference to the object to mutate it as a subsequent point. (If you wanted to mutate it immediately you would do it directly, no need to store the reference.)
As the function returns a value you could assign it to a const
reference (to a non-const
reference would be illegal) and extend the object's lifetime to the lifetime of the reference. However the effect would be exactly the same (const
aside) as storing the value in a object directly.
Any thought that it might be less efficient may well prove unfounded and you can qualify the object with const
if you want as well. (Most compilers eliminate the implied temporary and construct the return value in the object being initialized.)
As the object type is returned from the function by value it must be copyable so this is no reason to use a reference because of a concern that it isn't.