struct constructors and destructors.
Stefan Koch via Digitalmars-d
digitalmars-d at puremagic.com
Wed Jul 19 02:09:40 PDT 2017
On Wednesday, 19 July 2017 at 07:48:28 UTC, Danni Coy wrote:
> Is there a reason that the following code
>
> struct Foo
> {
> this (string name)
> { do_something(name); }
>
> ~this()
> { undo_something(); }
> }
>
> Foo foo = void;
>
> void open()
> {
> foo = Foo("test"); // <- this line
> }
>
> tries to OpAssign foo to itself then calls foo's destructor?
What happens is this.
void open()
{
foo = () {
Foo _tmp = Foo.__ctor("test");
return _tmp;
} ();
}
More information about the Digitalmars-d
mailing list