[Bug libstdc++/44436] [C++0x] Implement emplace* in associative and unordered containers

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Jun 9 13:14:00 GMT 2011


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

--- Comment #27 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-06-09 13:13:36 UTC ---
(In reply to comment #25)
> When I googled for this problem a year ago I've read that the second line
> doesn't work by *specification* and that you *have* to use emplace.

No, that's never been true.

The type of instancesByIds_[id] is a reference to the mapped_type, i.e.
unique_ptr<User>& and you have always been able to move assign to a unique_ptr
from an rvalue, by design.

You would have to use emplace for a container of objects which were not
copyable *or* movable, but unique_ptr is movable.



More information about the Gcc-bugs mailing list