June 30, 2004
If I pass an array element into a function expecting an inout parameter, this compiles fine fine:

void foo() {
	Object[] o;
	bar(o[0]);
}
void bar(inout Object x) {}

But if I do the same thing with a class with index overloads, I get the error "test.d(5): this.opIndex(0) is not an lvalue":

class Test {
	Object opIndex(int i) { return null; }
	Object opIndexAssign(Object o,int i) { return o; }
	void foo() {
		bar(this[0]);
	}
}
void bar(inout Object x) {}

I think I should be able to do this. It makes it trivial to overload foreach if you have indexers, and things like that.

Sam