Inserting to associative array do not return a lvalue.

Yang Bo pop.atry at gmail.com
Tue Oct 16 00:56:21 PDT 2007


I tend to write code like this:

int[int] a;
int* r = &(a[1] = 2); // error
(*r)++;

The problem is, `a[1] = 2` does not return a lvalue. I must write:

int[int] a;
a[1] = 2;
int* r = a[1];
(*r)++;

I have to look up the associative array twice, this is unwanted cost.



More information about the Digitalmars-d mailing list