http://d.puremagic.com/issues/show_bug.cgi?id=6581
--- Comment #8 from Kenji Hara <k.hara...@gmail.com> 2011-09-20 13:50:24 PDT --- Sorry, that was imcomplete. (In reply to comment #6) > Example: > ubyte[B.sizeof] mem=void; > emplace!B(mem.ptr);//Does this call to B's constructor call A's dtor on some > kind of trash then? void main() { ubyte[B.sizeof] mem=void; emplace!B(cast(void[])mem[]); writefln("%s %s %s", A.ctor, A.post, A.dtor);//prints 0 0 1 writefln("%s %s %s", B.ctor, B.post, B.dtor);//prints 0 0 1 // emplace calls A's ctor through calling B's ctor. } > And that's a problem. I mean even when emplace is working and all. Do we > really > want everybody to write emplace(&a, dummy); to do initialization in > constructor? > Seems very backwards. > I'd hate it if this will be some kind of rule #22 of how to do things > correctly > in D. I think the cases that actually needs emplace is rare. In most cases, it is rare that T.init has a meaningful state. (In this context, 'meaningful' means calling destructor against T.init does something. e.g. reference counter == 0, class reference == null, ...) Therefore, destructor calling with assignment against T.init like `a = A(dummy)` does not make problems usually. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------