struct constructors and destructors.
Stefan Koch via Digitalmars-d
digitalmars-d at puremagic.com
Wed Jul 19 05:34:50 PDT 2017
On Wednesday, 19 July 2017 at 12:23:06 UTC, Danni Coy wrote:
> On Wed, Jul 19, 2017 at 7:09 PM, Stefan Koch via Digitalmars-d
> < digitalmars-d at puremagic.com> wrote:
>
>>
>> What happens is this.
>>
>> void open()
>> {
>> foo = () {
>> Foo _tmp = Foo.__ctor("test");
>> return _tmp;
>> } ();
>> }
>>
>>
>> Error: need 'this' for 'this' of type 'ref Foo(string s)'
I posted pseudo code to show you that you are creating a
temporary.
Which leaves the scope after assigning.
And therefore triggers the destructor.
More information about the Digitalmars-d
mailing list