Bypassing the postblit?

Ali Çehreli acehreli at yahoo.com
Thu Dec 26 18:01:16 PST 2013


On 12/26/2013 05:43 PM, Ritu wrote:

 >> D struct copying is done by a bit-level copy of the source. A postblit
 >> - the closest we have to a struct copy constructor - is only run if
 >> you specify one yourself, i.e. there is no default one to disable.
 >
 > Thanks John
 >
 > Ok. Let me rephrase the question. I do not want to perform bit-wise copy
 > of my struct, but I want to specify my own copy semantics. Is there a 
way?

No. In D, struct are freely copied or moved depending on whether the 
source is an lvalue or an rvalue. What is possible is to define the 
post-blit function to work on the already-blitted destination object.

For example, if you don't want the source and the destination share a 
member slice, the destination object's post-blit can make a copy.

 > Regards
 > Ritu

Ali

P.S. There is also the D.learn newsgroup where such threads are enjoyed 
even more. :)



More information about the Digitalmars-d mailing list