Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Isn't the whole point of iterators to prevent the above strategy from crashing your program when the map is moved to another region of memory?


I'm not exactly sure what you mean by "the map is moved to another region of memory", but a pointer to the value object in a map entry is safe (or unsafe) in exactly the same situations as an iterator into the map. Under the hood, the iterator is likely to be a pointer to a tree node struct that contains the key and value objects (along with pointers to other relevant nodes).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: