PR libstdc++/87194 fix range insertion into maps and sets
authorJonathan Wakely <jwakely@redhat.com>
Mon, 3 Sep 2018 14:25:25 +0000 (15:25 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Mon, 3 Sep 2018 14:25:25 +0000 (15:25 +0100)
commit83a840a91fb3281f8980eaacdb7b5377778da3bb
tree2e92c6147aece7f85ca771a0c202e3d5d84e5e6e
parentbc62e155e412fd2230ec0538e2bef86211d26301
PR libstdc++/87194 fix range insertion into maps and sets

Since C++11 range insertion and construction of maps and sets from a
pair of iterators only requires that the iterator's value_type is
convertible to the container's value_type (previously it had to be the
same).

This fixes the implementation to meet that relaxed requirement, by
defining a pair of overloads that either insert or emplace, depending on
the iterator's value_type. Instead of adding yet another overload of
_M_insert_unique and _M_insert_equal, the overloads taking iterators are
renamed to _M_insert_range_unique and _M_insert_range_equal.

PR libstdc++/87194
* include/bits/stl_map.h
(map::map(initializer_list<value_type>, const Compare&, const Alloc&))
(map::map(initializer_list<value_type>, const Alloc&))
(map::map(InputIterator, InputIterator, const Alloc&))
(map::map(InputIterator, InputIterator))
(map::map(InputIterator, InputIterator, const Compare&, const Alloc&))
(map::insert(InputIterator, InputIterator)):
Call _M_insert_range_unique instead of _M_insert_unique.
* include/bits/stl_multimap.h
(multimap::multimap(initializer_list<value_type>, const C&, const A&))
(multimap::multimap(initializer_list<value_type>, const A&))
(multimap::multimap(InputIterator, InputIterator, const A&))
(multimap::multimap(InputIterator, InputIterator))
(multimap::multimap(InputIterator, InputIterator, const C&, const A&))
(multimap::insert(InputIterator, InputIterator)): Call
_M_insert_range_equal instead of _M_insert_equal.
* include/bits/stl_multiset.h
(multiset::multiset(InputIterator, InputIterator))
(multiset::multiset(InputIterator, InputIterator, const C&, const A&))
(multiset::multiset(initializer_list<value_type>, const C&, const A&))
(multiset::multiset(initializer_list<value_type>, const A&))
(multiset::multiset(InputIterator, InputIterator, const A&))
(multiset::insert(InputIterator, InputIterator)): Call
_M_insert_range_equal instead of _M_insert_equal.
* include/bits/stl_set.h
(set::set(InputIterator, InputIterator))
(set::set(InputIterator, InputIterator, const Compare&, const Alloc&))
(set::set(initializer_list<value_type>, const Compare&, const Alloc&))
(set::set(initializer_list<value_type>, const Alloc&))
(set::set(InputIterator, InputIterator, const Alloc&))
(set::insert(InputIterator, InputIterator)):
Call _M_insert_range_unique instead of _M_insert_unique.
* include/bits/stl_tree.h
[__cplusplus >= 201103L] (_Rb_tree::__same_value_type): New alias
template for SFINAE constraints.
[__cplusplus >= 201103L] (_Rb_tree::_M_insert_range_unique): Pair of
constrained overloads that either insert or emplace, depending on
iterator's value_type.
[__cplusplus >= 201103L] (_Rb_tree::_M_insert_range_equal): Likewise.
[__cplusplus < 201103L] (_Rb_tree::_M_insert_range_unique)
(_Rb_tree::_M_insert_range_equal): New functions replacing range
versions of _M_insert_unique and _M_insert_equal.
(_Rb_tree::_M_insert_unique(_InputIterator, _InputIterator))
(_Rb_tree::_M_insert_equal(_InputIterator, _InputIterator)): Remove.
* testsuite/23_containers/map/modifiers/insert/87194.cc: New test.
* testsuite/23_containers/multimap/modifiers/insert/87194.cc: New test.
* testsuite/23_containers/multiset/modifiers/insert/87194.cc: New test.
* testsuite/23_containers/set/modifiers/insert/87194.cc: New test.

From-SVN: r264060
libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/stl_map.h
libstdc++-v3/include/bits/stl_multimap.h
libstdc++-v3/include/bits/stl_multiset.h
libstdc++-v3/include/bits/stl_set.h
libstdc++-v3/include/bits/stl_tree.h
libstdc++-v3/testsuite/23_containers/map/modifiers/insert/87194.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/multimap/modifiers/insert/87194.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/multiset/modifiers/insert/87194.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/set/modifiers/insert/87194.cc [new file with mode: 0644]