> On 2015–06–16, at 12:28 AM, Róbert Dávid <
lrd...@gmail.com> wrote:
>
> I think the question was also about non-ordered containers.
>
> Sequence containers have to iterate through the sequence in order, obviously, but I actually see nothing to forbid unordered ones to iterate differently for a second time.
It’s all the way at the end, [unord.req] §23.2.5/15:
> The insert and emplace members shall not affect the validity of iterators if (N+n) < z * B, where N is the number of elements in the container prior to the insert operation, n is the number of elements inserted, B is the container’s bucket count, and z is the container’s maximum load factor.
Since unordered container iterators are ForwardIterators and thus have the multi-pass guarantee ([forward.iterators] §24.2.5/3), the order has to remain fixed until the load factor constraint allows a re-hash.
> I also see no reason for an implementation to do that though. Maybe with some garbage collection backed unordered_map
I’m interested to collect examples of containers implementing allocator-based garbage collection. Do you have an existing library in mind?