Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #7784
| From | Ian Collins <ian-news@hotmail.com> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: STL map insert Options |
| Date | 2011-07-14 07:57 +1200 |
| Message-ID | <986bn2FglrU4@mid.individual.net> (permalink) |
| References | <MPG.287d2c69abea9b739896c0@news.eternal-september.org> <526778d1-e768-4ee3-b42e-f8cc9444fab9@t8g2000prm.googlegroups.com> <983r38FglrU1@mid.individual.net> <a0b73b83-e7ac-431f-8778-ffcf1dd22c0e@h38g2000pro.googlegroups.com> |
On 07/14/11 02:31 AM, Stephen Howe wrote:
Please don't snip attributions, it's rude.
>> I'd be very surprised if all three didn't compile down to the same
>> assembly code. It certainly does with the two compilers I tried.
>>
>> Ian Collins
>
> I have just rechecked with Visual Studio 2008, 8 years later and I get
> the same results.
> And that is with full optimisations switched on.
> It is easy to see why as make_pair()/pair() are creating an actual
> object to insert, value_type does not. So that is an extra round of
> copy constructors/destructors.
> You might be using ints and the compilers you use might optimise out
> extra assignments.
>
> With the code referenced in the link, I get (and it is not too hard to
> work out what work map actually does).
If you change the code to use the same type as the map::value_type, all
things are equal. For example:
m.insert(pair<const Key, Value>(t2, tv));
<snip>
--
Ian Collins
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
STL map insert Options mrc2323@cox.net (Mike Copeland) - 2011-07-05 14:13 -0700
Re: STL map insert Options Ian Collins <ian-news@hotmail.com> - 2011-07-06 10:28 +1200
Re: STL map insert Options Paavo Helde <myfirstname@osa.pri.ee> - 2011-07-06 01:14 -0500
Re: STL map insert Options Stephen Howe <stephen.howe@kantarmedia.com> - 2011-07-12 13:29 -0700
Re: STL map insert Options Ian Collins <ian-news@hotmail.com> - 2011-07-13 09:01 +1200
Re: STL map insert Options Stephen Howe <stephen.howe@kantarmedia.com> - 2011-07-13 07:31 -0700
Re: STL map insert Options Leigh Johnston <leigh@i42.co.uk> - 2011-07-13 15:59 +0100
Re: STL map insert Options Ian Collins <ian-news@hotmail.com> - 2011-07-14 07:57 +1200
Re: STL map insert Options Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo> - 2011-07-14 00:07 -0400
Re: STL map insert Options Ian Collins <ian-news@hotmail.com> - 2011-07-14 16:50 +1200
Re: STL map insert Options Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-07-19 15:20 +0000
csiph-web