www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Can we have strcu with destructor have postblit disabled if none is

reply "deadalnix" <deadalnix gmail.com> writes:
I find myself reproducing the same pattern again and again, where 
I need to disable postblit on struct that have a sdestructor.

It doesn't make any sense and it is error prone. If the struct is 
copied, then the destructor is going to run twice and free the 
same resource twice, which is dangerous and incorrect.

Most C++ compiler warn nowadays about this. I don't think we 
should allow it at all in D.
Sep 05 2015
parent "ponce" <contact gam3sfrommars.fr> writes:
On Saturday, 5 September 2015 at 22:22:03 UTC, deadalnix wrote:
 Can we have strcu with destructor have postblit disabled if 
 none is provided ?
I also feel like post-blit should be opt-in.
Sep 06 2015