On 7/7/11 7:03 AM, Marijn Haverbeke wrote:
Shall we specify that temporary values, when put into a data
structure, are moved, rather than copied? For non-temporary values,
this usually not what you want, so we should provide an explicit
operator to specify that we want to move those.
I was going to implement copy constructor elision for this purpose.
There is a bug on this IIRC. The right thing to do is to neither move
nor copy, but actually write *directly* into the slot where the
temporary is going. The generated assembly code for typeck::check_expr,
for example, sorely needs this optimization.
Note that this is needed for resources to be at all usable:
auto x = my_resource();
would generate an error without some sort of copy constructor elision,
because the resource would be copied into a temporary for the return
value and then copied into "x", violating the noncopyability restriction.
Patrick
_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev