Aryeh Gregor writes:
> The compiler is required to use the move constructor (if one exists)
> instead of the copy constructor when constructing the return value of
> a function, and also when initializing an object from the return value
> of a function, or assigning the return value of a function. So if you
> have
>
> Foo GetFoo() { Foo f(1, 2, 7); /* do lots of stuff to f */ return f; }
> void MyFunction() { Foo f = GetFoo(); }
>
> the copy constructor of Foo will not get called anywhere.
I guess that means that with
struct Bar {
Bar(Foo f) : mF(f) {}
Foo GetFoo() { return mF; }
Foo mF;
}
GetFoo() would give away what mF owns?
If so, can we require that be more explicit somehow?
_______________________________________________
dev-platform mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-platform