Does associative array change the location of values?
Imperatorn
johan_forsberg_86 at hotmail.com
Sat Oct 30 20:19:58 UTC 2021
On Saturday, 30 October 2021 at 20:05:17 UTC, Stanislav Blinov
wrote:
> On Saturday, 30 October 2021 at 18:31:16 UTC, Andrey Zherikov
> wrote:
>
>> I did small test and it printed the same values three times so
>> even rehash doesn't change the address of the value:
>
>> So it seems pretty safe to store a pointer to a value in AA.
>> And I agree that this should definitely be documented.
>
> Address itself may change though. While the AA won't move stuff
> around, a GC might. I don't think current GC moves anything,
> but it's definitely allowed to. Which would be transparent to
> your code so long as you don't depend on the value of address
> itself :)
>
> https://dlang.org/spec/garbage.html#pointers_and_gc
What test could be written to verify the behaviour?
More information about the Digitalmars-d-learn
mailing list