Struct that destroys its original handle on copy-by-value

Adam D. Ruppe via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Jul 29 12:10:34 PDT 2015


On Sunday, 26 July 2015 at 12:16:30 UTC, Joseph Rushton Wakeling 
wrote:
> My aim by contrast is to _allow_ that kind of use, but render 
> the original handle empty when it's done.

I don't think D offers any way to do that. With the disabled 
postblit, you can force people into a method you write that 
returns a new copy and clears the original, but that won't just 
work with assignment.

The ref assign might not be forbidden by the written doc but I'm 
guessing that is just an oversight - struct assignment in D  
never clears the original, it is always a simple copy (perhaps 
plus other code)....


More information about the Digitalmars-d-learn mailing list