1 struct X { 2 int* rc; thisX3 this (int n) { auto x = new int[](1); rc = x.ptr; *rc = n; } thisX4 this (this) { ++*rc; } ~thisX5 ~this () { --*rc; } 6 @disable void opAssign (X src); 7 } 8 9 struct Y { 10 X x; 11 } 12 frob(X x)13void frob(X x) 14 { 15 Y y = { x: x }; 16 // The 'rc' counter starts from 1 and gets bumped when: 17 // - 'f0' is passed to 'frob' 18 // - 'y' is initialized with 'x' 19 assert(*y.x.rc == 3); 20 } 21 main()22void main () 23 { 24 auto f0 = X(1); 25 frob(f0); 26 } 27