Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #119588
| From | usenet@stegropa.de (Stefan Große Pawig) |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: std::map::emplace useful in any way? |
| Date | 2024-06-30 21:09 +0200 |
| Organization | Dark Sky |
| Message-ID | <87jzi6gsct.fsf@ID-208667.user.individual.de> (permalink) |
| References | <v2t1pv$1bdc2$1@gwaiyur.mb-net.net> |
Marcel Mueller <news.5.maazl@spamgourmet.org> writes: > The emplace functions generally allows to construct container objects > directly at the target location. But std::map expects a value type of > std::pair<const Key, T>. Now the implementation of emplace needs to > instantiate the value type just to get the key to find the insert > location. This cannot happen at the target location, isn't it? > > I know, this has been solved in C++17 by try_emplace. I just wonder what > was the idea of this function. While the value type may be instantiated and immediately destroyed when it turns out that an element with the same key already exists, emplace() still allows you to insert values that are neither copyable nor moveable. Stefan
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
std::map::emplace useful in any way? Marcel Mueller <news.5.maazl@spamgourmet.org> - 2024-05-25 17:57 +0200
Re: std::map::emplace useful in any way? Paavo Helde <eesnimi@osa.pri.ee> - 2024-05-25 20:37 +0300
Re: std::map::emplace useful in any way? Bonita Montero <Bonita.Montero@gmail.com> - 2024-05-28 17:53 +0200
Re: std::map::emplace useful in any way? Paavo Helde <eesnimi@osa.pri.ee> - 2024-05-29 11:11 +0300
Re: std::map::emplace useful in any way? Bonita Montero <Bonita.Montero@gmail.com> - 2024-05-29 11:47 +0200
Re: std::map::emplace useful in any way? Paavo Helde <eesnimi@osa.pri.ee> - 2024-05-29 15:05 +0300
Re: std::map::emplace useful in any way? Bonita Montero <Bonita.Montero@gmail.com> - 2024-05-29 18:56 +0200
Re: std::map::emplace useful in any way? "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-05-29 12:23 -0700
Re: std::map::emplace useful in any way? Bonita Montero <Bonita.Montero@gmail.com> - 2024-05-30 16:01 +0200
Re: std::map::emplace useful in any way? Bonita Montero <Bonita.Montero@gmail.com> - 2024-05-25 19:41 +0200
Re: std::map::emplace useful in any way? Andrey Tarasevich <andreytarasevich@hotmail.com> - 2024-06-30 09:47 -0700
Re: std::map::emplace useful in any way? Bonita Montero <Bonita.Montero@gmail.com> - 2024-06-30 19:15 +0200
Re: std::map::emplace useful in any way? Andrey Tarasevich <andreytarasevich@hotmail.com> - 2024-06-30 11:46 -0700
Re: std::map::emplace useful in any way? usenet@stegropa.de (Stefan Große Pawig) - 2024-06-30 21:21 +0200
Re: std::map::emplace useful in any way? Bonita Montero <Bonita.Montero@gmail.com> - 2024-06-30 23:49 +0200
Re: std::map::emplace useful in any way? Andrey Tarasevich <andreytarasevich@hotmail.com> - 2024-06-30 18:29 -0700
Re: std::map::emplace useful in any way? Bonita Montero <Bonita.Montero@gmail.com> - 2024-07-01 13:41 +0200
Re: std::map::emplace useful in any way? Bonita Montero <Bonita.Montero@gmail.com> - 2024-07-07 13:17 +0200
Re: std::map::emplace useful in any way? Andrey Tarasevich <andreytarasevich@hotmail.com> - 2024-07-07 09:16 -0700
Re: std::map::emplace useful in any way? Bonita Montero <Bonita.Montero@gmail.com> - 2024-07-07 18:18 +0200
Re: std::map::emplace useful in any way? usenet@stegropa.de (Stefan Große Pawig) - 2024-07-01 07:41 +0200
Re: std::map::emplace useful in any way? Sam <sam@email-scan.com> - 2024-05-25 18:29 -0400
Re: std::map::emplace useful in any way? usenet@stegropa.de (Stefan Große Pawig) - 2024-06-30 21:09 +0200
Re: std::map::emplace useful in any way? Andrey Tarasevich <andreytarasevich@hotmail.com> - 2024-06-30 13:32 -0700
Re: std::map::emplace useful in any way? Marcel Mueller <news.5.maazl@spamgourmet.org> - 2024-07-07 11:09 +0200
csiph-web