This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/54064] New: C++11 unordered_map emplace


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54064

             Bug #: 54064
           Summary: C++11 unordered_map emplace
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: martin.alex32@hotmail.fr


Hello,

Sorry for my english I'm french.

I noticed an issue with std::unordered_map::emplace member function: it should
use the first variadic argument to construct the key, and the other arguments
to construct a mapped_type object, instead of constructing directly a std::pair
object.

For example, we should be able to do that:
std::unordered_map<int, std::pair<int, int>> m;
m.emplace(1, 2, 3);

instead of:
std::unordered_map<int, std::pair<int, int>> m;
m.emplace(1, std::make_pair(2, 3));

It would be useful to correct this function because it would avoid an extra
move operation.

Thank you


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]