associative arrays

simendsjo simendsjo at gmail.com
Sun Jan 8 05:57:51 PST 2012


On 08.01.2012 14:40, Jonathan M Davis wrote:
> On Sunday, January 08, 2012 14:24:32 simendsjo wrote:
>> Thanks for your clarifications.
>>
>> Does this mean even this is undefined?
>> aa["a"] = new C();
>> auto c = "a" in aa;
>> aa["b"] = new C();
>> // Using c here is undefined as an element was added to aa
>
> Yes. Depending on the current implementation of AAs and the state of aa when
> "b" is added to it, c could still point to exactly what it did before, or aa
> could have been rehashed, which could move any or all of its elements around,
> in which case who knows what c points to.
>
> - Jonathan M Davis

Thanks! You've saved me a couple of future bugs :)


More information about the Digitalmars-d-learn mailing list