PR libstdc++/78595 implement insertion into maps in terms of emplace
authorJonathan Wakely <jwakely@redhat.com>
Mon, 3 Sep 2018 14:25:12 +0000 (15:25 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Mon, 3 Sep 2018 14:25:12 +0000 (15:25 +0100)
commitbc62e155e412fd2230ec0538e2bef86211d26301
treed1599d3dc442dce5d10470f835ebc341956a59ae
parenta6b75a69dae0cfaa9085708073ebd1853e0e6102
PR libstdc++/78595 implement insertion into maps in terms of emplace

C++14 simplified the specification of the generic insert function
templates to be equivalent to calling emplace (or emplace_hint).
Defining them in terms of emplace takes care of the problems described
in PR 78595, ensuring a single conversion to value_type is done at the
right time.

PR libstdc++/78595
* include/bits/stl_map.h (map::insert(_Pair&&))
(map::insert(const_iterator, _Pair&&)): Do emplace instead of insert.
* include/bits/stl_multimap.h (multimap::insert(_Pair&&))
(multimap::insert(const_iterator, _Pair&&)): Likewise.
* include/bits/unordered_map.h (unordered_map::insert(_Pair&&))
(unordered_map::insert(const_iterator, _Pair&&))
(unordered_multimap::insert(_Pair&&))
(unordered_multimap::insert(const_iterator, _Pair&&)): Likewise.
* testsuite/23_containers/map/modifiers/insert/78595.cc: New test.
* testsuite/23_containers/multimap/modifiers/insert/78595.cc: New test.
* testsuite/23_containers/unordered_map/modifiers/78595.cc: New test.
* testsuite/23_containers/unordered_multimap/modifiers/78595.cc: New
test.

From-SVN: r264059
libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/stl_map.h
libstdc++-v3/include/bits/stl_multimap.h
libstdc++-v3/include/bits/unordered_map.h
libstdc++-v3/testsuite/23_containers/map/modifiers/insert/78595.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/multimap/modifiers/insert/78595.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/unordered_map/modifiers/78595.cc [new file with mode: 0644]
libstdc++-v3/testsuite/23_containers/unordered_multimap/modifiers/78595.cc [new file with mode: 0644]