DIP 1018--The Copy Constructor--Community Review Round 1

Kagamin spam at here.lot
Wed Dec 19 11:53:12 UTC 2018

I think const postblit can be done by creating shadow copy of 
instance fields (but still physically located in the field).

struct A
     int b;
     this(this) immutable
         immutable int shadow_b; //reads go here
         immutable int t=shadow_b;

Type system would treat them as distinct instances, but would 
destroy shadow copy right before assignment, after which shadow 
copy's lifetime ends and it goes out of scope completely, which 
will also invalidate any retained pointers if any.

More information about the Digitalmars-d mailing list