I found this in the standard as the post-condition for the rehash function in unordered associative containers :
Post: a.bucket_count() > a.size() / a.max_load_factor() and a.bucket_count() >= n.
(n being the number of buckets in the container)
Can I take the above to mean that an automatic rehashing is triggered when either of the above conditions is met for all implementations? Or, are implementations free to decide when to rehash and the above only pertains to the rehash function?
The implementation shall keep the
load_factor() <= max_load_factor()andload_factor() == size() / bucket_count(). So automatic rehashing can occur during aninsertto keep the load factor invariant.Although the
load_factor()can not exceedmax_load_factor(), I don’t think there is a guarantee that no rehashing will be done during an insert even if you can prove that this invariant will not be violated.Definition for
max_load_factoris: