Re: Struct dtor on ref variable

2016-08-01 Thread Patric via Digitalmars-d-learn
On Monday, 1 August 2016 at 16:05:51 UTC, Steven Schveighoffer wrote: On 8/1/16 12:01 PM, Patric wrote: I expected nothing to happen because "ref" its a simple pointer, right? Or I am missing something here? You want opAssign, not opOpAssign. opOpAssign is for things like +=. Your code h

Re: Struct dtor on ref variable

2016-08-01 Thread Patric via Digitalmars-d-learn
On Monday, 1 August 2016 at 16:21:16 UTC, Mike Parker wrote: On Monday, 1 August 2016 at 16:18:32 UTC, Patric wrote: But still. If it was the case of "+=" wasn´t wrong to call the dtor since is a ref var? No. It was working as expected. You never implemented opAssign, so default assignment

Re: Struct dtor on ref variable

2016-08-01 Thread Mike Parker via Digitalmars-d-learn
On Monday, 1 August 2016 at 16:18:32 UTC, Patric wrote: But still. If it was the case of "+=" wasn´t wrong to call the dtor since is a ref var? No. It was working as expected. You never implemented opAssign, so default assignment was being used. There was no ref variable.

Re: Struct dtor on ref variable

2016-08-01 Thread Mike Parker via Digitalmars-d-learn
On Monday, 1 August 2016 at 16:17:02 UTC, Patric wrote: On Monday, 1 August 2016 at 16:05:51 UTC, Steven Schveighoffer wrote: On 8/1/16 12:01 PM, Patric wrote: I expected nothing to happen because "ref" its a simple pointer, right? Or I am missing something here? You want opAssign, not opO

Re: Struct dtor on ref variable

2016-08-01 Thread Mike Parker via Digitalmars-d-learn
On Monday, 1 August 2016 at 16:14:31 UTC, Patric wrote: On Monday, 1 August 2016 at 16:05:51 UTC, Steven Schveighoffer wrote: On 8/1/16 12:01 PM, Patric wrote: I expected nothing to happen because "ref" its a simple pointer, right? Or I am missing something here? You want opAssign, not opO

Re: Struct dtor on ref variable

2016-08-01 Thread Patric via Digitalmars-d-learn
On Monday, 1 August 2016 at 16:05:51 UTC, Steven Schveighoffer wrote: On 8/1/16 12:01 PM, Patric wrote: I expected nothing to happen because "ref" its a simple pointer, right? Or I am missing something here? You want opAssign, not opOpAssign. opOpAssign is for things like +=. Your code h

Re: Struct dtor on ref variable

2016-08-01 Thread Patric via Digitalmars-d-learn
On Monday, 1 August 2016 at 16:05:51 UTC, Steven Schveighoffer wrote: On 8/1/16 12:01 PM, Patric wrote: I expected nothing to happen because "ref" its a simple pointer, right? Or I am missing something here? You want opAssign, not opOpAssign. opOpAssign is for things like +=. Your code h

Re: Struct dtor on ref variable

2016-08-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/1/16 12:01 PM, Patric wrote: I expected nothing to happen because "ref" its a simple pointer, right? Or I am missing something here? You want opAssign, not opOpAssign. opOpAssign is for things like +=. Your code had me worried for a while :) -Steve

Struct dtor on ref variable

2016-08-01 Thread Patric via Digitalmars-d-learn
struct Test{ int x; this(int v){ x = v; writeln(x.to!string ~ " Created"); } ~this(){ writeln(x.to!string ~ " Destroyed"); } void opOpAssign(string op, Type)(ref Type s){ x = s.x;