C++ has the issue of iterator invalidation, where certain operations on a container while iterating on it may invalidate the iterator, in which case it is no longer safe to use the iterator.

D has ranges, but presumably the same issue can arise in D. For instance, if I have a ForwardRange and I use the save primitive to keep a reference to some tail of it, then I can manipulate one of the ranges in a way that may leave the other in an undefined state. For instance, if the range is allocated on the heap and at some point I free its memory, then the range's copy is going to point to some garbage.

Is there some documentation anywhere on:
1. Primitive operations, e.g. concatenation, that may invalidate a range. 2. Funtions in Phobos, operating on a range, e.g. (filter, sort, etc.), that may invalidate it?

Thanks. -Mark

Reply via email to