On 6/21/15 7:31 PM, Steven Schveighoffer wrote:
On 6/21/15 7:02 PM, Andrei Alexandrescu wrote:
While I work on making std.allocator better, here's some food for
thought regarding std.collection.

Consider a traditional container with reference semantics, Java-style.
Regarding changing the collection (e.g. adding/removing elements) while
iterating, we have the following possibilities:

1. Leave it undefined, like the STL does. Probably this is too extreme.

I don't think it's undefined, it depends on the container:

http://www.cplusplus.com/reference/set/set/erase/

"Iterators, pointers and references referring to elements removed by the
function are invalidated. All other iterators, pointers and references
keep their validity."

"Invalidated" = undefined. The point is to make it a hard error when trying to use an invalidated range. -- Andrei


Reply via email to