[Issue 5115] std.typecons.scoped problems

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Dec 21 01:02:14 PST 2010


http://d.puremagic.com/issues/show_bug.cgi?id=5115



--- Comment #8 from yebblies <yebblies at gmail.com> 2010-12-21 01:00:19 PST ---
(In reply to comment #7)
> (In reply to comment #6)
> > You are probably right. Then why isn't this a compile error?
> > 
> > Foo f1 = scoped!Foo();
> 
> Because Scoped!Foo has an 'alias this' to the underlying Foo, which is
> necessary for it to behave like a Foo.

scoped!Foo() returns a temporary of type scoped!(Foo).Scoped (or something like
that).
This temporary is implicitly converted to Foo using alias this, but the
temporary never has it's destructor called due to bug 3516, which means Foo's
destructor is never called either.

It is fine for the temporary to be converted to Foo, so long as the destructor
is called when the scope that 'scoped' was called in is exited.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list