[Bug libstdc++/78595] Unnecessary copies in _Rb_tree

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Sep 3 14:26:00 GMT 2018


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78595

--- Comment #13 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Author: redi
Date: Mon Sep  3 14:25:12 2018
New Revision: 264059

URL: https://gcc.gnu.org/viewcvs?rev=264059&root=gcc&view=rev
Log:
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.

Added:
    trunk/libstdc++-v3/testsuite/23_containers/map/modifiers/insert/78595.cc
   
trunk/libstdc++-v3/testsuite/23_containers/multimap/modifiers/insert/78595.cc
    trunk/libstdc++-v3/testsuite/23_containers/unordered_map/modifiers/78595.cc
   
trunk/libstdc++-v3/testsuite/23_containers/unordered_multimap/modifiers/78595.cc
Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/include/bits/stl_map.h
    trunk/libstdc++-v3/include/bits/stl_multimap.h
    trunk/libstdc++-v3/include/bits/unordered_map.h


More information about the Gcc-bugs mailing list