How to turn this C++ into D?
luminousone via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Nov 5 10:56:06 PST 2014
On Wednesday, 5 November 2014 at 18:18:18 UTC, Ali Çehreli wrote:
> On 11/05/2014 10:12 AM, Adam D. Ruppe wrote:
>
> > On Wednesday, 5 November 2014 at 18:10:38 UTC, Ali Çehreli
> wrote:
> >> If so, then that push_back would be adding an incomplete
> object to the
> >> list.
> >
> > scope(success)?
>
> I really like that! :)
>
> But still not for this case because in addition to the problem
> with the destruction order, I would like to feel free to remove
> unused objects like the following without worrying about
> side-effects:
>
> // C++ code
> void bar()
> {
> Foo seemingly_unused_here();
> // ...
> }
>
> Ali
unless delete is explicitly called, I don't believe the
destructor would ever be called, it would still have a reference
in the static foo_list object that would stop it from being
collected by the gc.
I could see the constructor situation being a problem in threaded
code as well, tho it may be bad practice, I don't believe the
insert(this) would actually break anything.
The scope(success) is a good idea either way however.
More information about the Digitalmars-d-learn
mailing list