4 ms·
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?
by HappySweeney 8y ago
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?
- quietbritishjim 8y agoI'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).