Works fine. :) Now my little test case work as expected:
[code] import std.stdio; class Test { public: this() { writeln("CTor"); } ~this() { writeln("DTor"); } void echo() const { writeln("Here is Test"); } } struct scoped { private: Test* _t; public: this(ref Test t) { this._t = &t; writeln(" >> scoped CTor"); } @disable this(this); ref scoped opAssign(ref Test t) { this.Release(); this._t = &t; writeln(" >> scoped Assign"); return this; } ~this() { writeln(" >> scoped DTor"); this.Release(); } void Release() { if (this._t !is null && *this._t !is null) { writeln("Clear scoped content"); clear(*this._t); *this._t = null; this._t = null; } } @property Test* Value() { return this._t; } alias Value this; } class Bar { private: scoped _sc; public: this(ref Test f) { writeln("begin this"); this._sc = f; writeln("end this"); } ~this() { writeln("DTOR BAR"); } } void main() { Test t = new Test(); clear(t); Test t2 = new Test(); { scoped s = t2; s.echo(); writeln("end scope"); } assert(t2 is null); Test t3 = new Test(); Bar b = new Bar(t3); assert(t3 !is null); writeln("end main"); } [/code]