re PR libstdc++/83709 (Inserting duplicates into an unordered associative containers...
authorFrançois Dumont <fdumont@gcc.gnu.org>
Tue, 9 Jan 2018 21:05:10 +0000 (21:05 +0000)
committerFrançois Dumont <fdumont@gcc.gnu.org>
Tue, 9 Jan 2018 21:05:10 +0000 (21:05 +0000)
commit0f1462579e348656b9a5549721f926d6f5894e1c
treef299bb47be49fefdcc1c4f42f77dac57c278a88f
parent19d22f7c90d87eb9a3c5715cfa59407e2baeabbc
re PR libstdc++/83709 (Inserting duplicates into an unordered associative containers causes the container to invalidate iterators)

2018-01-09  François Dumont  <fdumont@gcc.gnu.org>

PR libstdc++/83709
* include/bits/hashtable_policy.h
(__distance_fwd(_Iterator, _Iterator, input_iterator_tag)): Return 1 if
__first != __last.
(_Insert_base::_M_insert_range(_Ite, _Ite, _NodeGetter, true_type)): New.
(_Insert_base::_M_insert_range(_Ite, _Ite, _NodeGetter, false_type)):
Add false_type parameter.
(_Insert_base::insert): Adapt.
* include/bits/hashtable.h (_Hashtable::operator=(initializzr_list<>)):
Adapt.
(_Hashtable::_M_insert(_Arg&&, const _NodeGen&, true_type, size_t)):
 Add __n_elt parameter, defaulted to 1.
(_Hashtable::_M_insert_unique_node): Likewise. Use it to call rehash
policy _M_need_rehash.
(_Hashtable::_M_merge_unique): Pass target number of elements to add to
produce only 1 rehash if necessary.
* testsuite/23_containers/unordered_map/insert/83709.cc: New.
* testsuite/23_containers/unordered_set/insert/83709.cc: New.

From-SVN: r256396
libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/hashtable.h
libstdc++-v3/include/bits/hashtable_policy.h
libstdc++-v3/testsuite/23_containers/unordered_map/insert/83709.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/unordered_set/insert/83709.cc [new file with mode: 0644]