[Dlang-internal] DIP1000 simple scopebuffer

Walter Bright via Dlang-internal dlang-internal at puremagic.com
Mon Oct 24 14:02:05 PDT 2016


@safe struct ScopeBuffer
{
   private:
     int[10] buffer;

   public:
     ref int opIndex(size_t i) return
     {
         return buffer[i];
     }
}

Yes, a real one would be more complex, but that's the basic idea. The ref 
returns are tied to the instance of the ScopeBuffer.


More information about the Dlang-internal mailing list