On Mon, 20 Jun 2011 18:43:30 -0400, Jonathan M Davis <[email protected]>
wrote:
On 2011-06-20 15:12, Steven Schveighoffer wrote:
BTW, I now feel that your request to make a distinction between move and
copy is not required. The compiler currently calls the destructor of
temporaries, so it should also call postblit. I don't think it can make
the distinction between array appending and simply calling some other
function.
If an object is moved, neither the postblit nor the destructor should be
called. The object is moved, not copied and destroyed. I believe that
TDPL is
very specific on that.
Well, I think in this case it is being copied. It's put on the stack, and
then copied to the heap inside the runtime function. The runtime could be
passed a flag indicating the append is really a move, but I'm not sure
it's a good choice. To me, not calling the postblit and dtor on a moved
struct is an optimization, no? And you can't re-implement these semantics
for a normal function. The one case I can think of is when an rvalue is
allowed to be passed by reference (which is exactly what's happening here).
Is there anything a postblit is allowed to do that would break a struct if
you disabled the postblit in this case? I'm pretty sure internal pointers
are not supported, especially if move semantics do not call the postblit.
-Steve