with statement doesn't call struct destructor?

simendsjo simen.endsjo at pandavre.com
Wed Jun 8 13:31:57 PDT 2011


import std.stdio;
void main() {
     struct S {
         this(bool a) { writeln(" this"); }
         ~this() { writeln(" ~this"); }
     }

     writeln("scoped:");
     {
         auto s = S(true);
     }

     writeln("with:");
     with(S(true)) {
     }
}

Output:

scoped:
  this
  ~this
with:
  this


More information about the Digitalmars-d-learn mailing list