This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/44436] [C++0x] Implement emplace* in associative and unordered containers
- From: "Kira.Backes at NRWsoft dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 9 Jun 2011 12:21:08 +0000
- Subject: [Bug libstdc++/44436] [C++0x] Implement emplace* in associative and unordered containers
- Auto-submitted: auto-generated
- References: <bug-44436-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44436
--- Comment #21 from Kira Backes <Kira.Backes at NRWsoft dot de> 2011-06-09 12:21:07 UTC ---
Hi,
I don't mean a pair of unique_ptr, just any combination with a unique_ptr.
I for example very often need:
std::map<uint32_t, unique_ptr<User>> instancesByIds_;
Now if I want to insert a User, with a shared_ptr I'd have to do:
instancesByIds_[id] = user;
Now with a unique_ptr I'd like to do the same:
instancesByIds_[id] = user;
instancesByIds_[id] = std::move(user);
Both doesnt work. Emplace is the practical solution (please correct me if
there's a better way):
instancesByIds_.emplace(id, std::move(user));
rgds, Kira