Assuming I have:
- class A which is non-copyable
- class B which has as a member, const A& a (and takes an A in its constructer and sets it in its initialization list)
- a function
A GenerateA();
Does this mean that it should be valid to do: B(GenerateA()) ?
i.e, does the const ref mean that no copy of the A that generateA() returns is done? And does that mean that the scope of the returned temporary is extended for as long as B exists?
EDIT: Addon question from the comments: Is it acceptable to return a A& from GenerateA() to a local A, if the lvalue is a const A&?
Thanks!