Re: Problem with dtor behavior

2017-07-28 Thread SrMordred via Digitalmars-d-learn
On Friday, 28 July 2017 at 16:25:01 UTC, Adam D. Ruppe wrote: On Thursday, 27 July 2017 at 19:19:27 UTC, SrMordred wrote: "auto ref means ref for lvalues, value for rvalues." Iep, my confusion was there. My mind is still wrapped around the rvalue references and move semantics of c++

Re: Problem with dtor behavior

2017-07-28 Thread SrMordred via Digitalmars-d-learn
On Friday, 28 July 2017 at 15:49:42 UTC, Moritz Maxeiner wrote: [...] Nice, a bit more clear now, thank you!

Re: Problem with dtor behavior

2017-07-28 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 27 July 2017 at 19:19:27 UTC, SrMordred wrote: void push(T)(auto ref T value){ push(MyStruct(1)); template void push(T&& value){ push(MyStruct(1)); Those aren't the same... the D one will pass by value, the C++ one won't. D's auto ref means ref for lvalues, value for

Re: Problem with dtor behavior

2017-07-28 Thread Moritz Maxeiner via Digitalmars-d-learn
On Friday, 28 July 2017 at 11:39:56 UTC, SrMordred wrote: On Thursday, 27 July 2017 at 20:28:47 UTC, Moritz Maxeiner wrote: On Thursday, 27 July 2017 at 19:19:27 UTC, SrMordred wrote: //D-CODE struct MyStruct{ int id; this(int id){ writeln("ctor"); } ~this(){

Re: Problem with dtor behavior

2017-07-28 Thread SrMordred via Digitalmars-d-learn
On Thursday, 27 July 2017 at 20:28:47 UTC, Moritz Maxeiner wrote: On Thursday, 27 July 2017 at 19:19:27 UTC, SrMordred wrote: //D-CODE struct MyStruct{ int id; this(int id){ writeln("ctor"); } ~this(){ writeln("dtor"); } } MyStruct* obj; void push(T)(auto

Re: Problem with dtor behavior

2017-07-27 Thread Moritz Maxeiner via Digitalmars-d-learn
On Thursday, 27 July 2017 at 19:19:27 UTC, SrMordred wrote: //D-CODE struct MyStruct{ int id; this(int id){ writeln("ctor"); } ~this(){ writeln("dtor"); } } MyStruct* obj; void push(T)(auto ref T value){ obj[0] = value; } void main() { obj =

Problem with dtor behavior

2017-07-27 Thread SrMordred via Digitalmars-d-learn
//D-CODE struct MyStruct{ int id; this(int id){ writeln("ctor"); } ~this(){ writeln("dtor"); } } MyStruct* obj; void push(T)(auto ref T value){ obj[0] = value; } void main() { obj = cast(MyStruct*)malloc( MyStruct.sizeof ); push(MyStruct(1)); }