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

--- Comment #26 from Haakan Younes <hyounes at google dot com> 2011-06-09 
13:03:19 UTC ---
(In reply to comment #18)
> (In reply to comment #15)
> > Is it really so hard to code emplace methods? Can we somehow help?
> 
> It's not so hard, but we have limited resources and other priorities.
> 
> Patches welcome, see
> http://gcc.gnu.org/onlinedocs/libstdc++/manual/appendix_contributing.html

I started looking into it about a year ago, before you added insert(&&).  It
seems easy enough to add emplace for map, but what about set?

For map, the first argument to emplace is going to be the key (I believe).  We
can therefore determine if the key is already present in the map before we
construct the value object from the remaining arguments to emplace.

For set, the key is the value, so I don't see a way to avoid constructing the
value object from the arguments to emplace before you know if it should be
inserted.

Am I thinking about it the wrong way?

BTW, I have been happily using insert(&&) for maps for at least 6 months (GCC
built from trunk).  I strongly suspect it is available with GCC 4.6.  You
definitely do not need emplace to store unique_ptr values in a map.

Reply via email to