Calls `this(this)` extra with delegate stuff in the code
    Ali Çehreli via Digitalmars-d-learn 
    digitalmars-d-learn at puremagic.com
       
    Sat Jan 21 15:19:57 PST 2017
    
    
  
Simplified:
import std.stdio;
struct Widget {
     private int[] array;
     this(uint length) {
         array = new int[length];
         writefln("ctor called      : %s", array.ptr);
     }
     this(this) {
         writef( "this(this) called: %s", array.ptr );
         array = array.dup;
         writefln(" -> %s", array.ptr);
     }
}
void main() {
     auto w1 = Widget(10);
     writeln(w1);
}
It's due to the copies that are made when calling writeln and other 
functions that it calls.
Ali
    
    
More information about the Digitalmars-d-learn
mailing list