Problem with associative arrays

Jesse Phillips jessekphillips+D at gmail.com
Sun Mar 20 10:07:38 PDT 2011


Piotr Szturmaj Wrote:

> Yes, I already used pointers but in other way:
> 
> uint[]* temp = &aa[5]; // copy uint[] reference
> 
> and it worked the same as using 'in'. However, I wasn't sure it's 
> completely safe.

Depends on what you mean by "safe." In your example if 5 is not a key then a Range violation will be thrown. In mine null will be returned.

Generally safety refers to not corrupting memory, and under that definition both of these are safe. Under the definition of "will not crash" no solution is safe.


More information about the Digitalmars-d-learn mailing list