@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.