On 4/10/2015 2:50 PM, Michel Fortin wrote:
And how is it pinned in this case?

  struct S {
      private RCArray!T array;
      ref T opIndex(int index) return { return array[index]; }
      void clear() { s.array = RCArray!T([]); }
  }
  void main() {
      auto s = S(RCArray!T([T()])); // s.array's refcount is now 1
      foo(s, s[0]);           // pass by ref

The s[0] is preceded by tmp=s; Because T is reachable from typeof(first 
argument s)

  }
  void foo(ref S s, ref T t) {
      s.clear();            // drop the old s.array
      t.doSomething();              // oops, t is gone
  }


Reply via email to