🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #1897

Re: insert for map and multimap

#1897
From: J. Kanze
Date: Sun, 03 Sep 1995 16:06
35 lines
1978 bytes
John Max Skaller (maxtal@suphys.physics.su.oz.au) wrote:
|> ajay@lehman.com (Ajay Kamdar) wrote:
|> >>:Given a multimap, this is what I would have *liked* to do:
|> >>
|> >>:    multimap<int,double> m;
|> >>:    m.insert(3, 5.0);
|> >
|> >But what I can't understand is why the proposed standard is the way it
|> >is.

|> Well, one reason is consistency. A container has a SINGLE kind of element,
|> in the case of map and multimap it's pair<key,value>. Thats what an iterator
|> enumerating the container contents sees. This is important in cases like:

|>     map1.insert( *map2.begin() );

|> which is very much better than

|>     pair<key,value> item = *map2.begin();
|>     map1.insert( item.first, item.second);


|> . don't you think?

But one doesn't prevent the other, does it?  Or is there some reason why
multimap::insert should not be overloaded?
-- 
James Kanze           (+33) 88 14 49 00          email: kanze@gabi-soft.fr
GABI Software, Sarl., 8 rue des Francs Bourgeois, 67000 Strasbourg, France
Conseils en informatique industrielle--
                             --Beratung in industrieller Datenverarbeitung

[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID: <42cik3$1h3@gabi.gabi-soft.fr>
Path: arc1-ca.pugleaf.net!engnews2.Eng.Sun.COM!taumet!clamage
References: <9508170857.ZM22058@jabba> <411h8u$fi8@cyber.tn.tudelft.nl> <41fhcu$kgp@engnews2.Eng.Sun.COM> <421ri8$k3k@oznet03.ozemail.com.au>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!engnews2.Eng.Sun.COM!taumet!clamage
From: kanze@gabi-soft.fr (J. Kanze)
Newsgroups: comp.std.c++
Subject: Re: insert for map and multimap
Date: 3 Sep 1995 16:06:03 GMT
Organization: GABI Software, Sarl.
Approved: clamage@eng.sun.com (comp.std.c++)
Message-ID: <42cik3$1h3@gabi.gabi-soft.fr>
References: <9508170857.ZM22058@jabba> <411h8u$fi8@cyber.tn.tudelft.nl> <41fhcu$kgp@engnews2.Eng.Sun.COM> <421ri8$k3k@oznet03.ozemail.com.au>
NNTP-Posting-Host: taumet.eng.sun.com
Content-Type: text
X-Newsreader: TIN [version 1.2 PL2]
Content-Length: 1129
Originator: clamage@taumet