Article View: comp.std.c++
Article #1828Re: insert for map and multimap
From: Ajay Kamdar
Date: Wed, 23 Aug 1995 15:27
Date: Wed, 23 Aug 1995 15:27
67 lines
3296 bytes
3296 bytes
In article <411h8u$fi8@cyber.tn.tudelft.nl>,
Klamer Schutte <klamer@ph.tn.tudelft.nl> wrote:
>In <9508170857.ZM22058@jabba> ajay@lehman.com (Ajay Kamdar) writes:
>
>:Given a multimap, this is what I would have *liked* to do:
>
>: multimap<int,double> m;
>: m.insert(3, 5.0);
>
>I also would like to see the insert member described above.
>
>You of course can make a child class of multimap with the insert member
>you want. Or you can use the function below:
>
>template <class Key, class T, class Compare>
>inline void
>map_insert( multimap<Key,T,Compare > &m, const Key &k, const T &v )
>{
>m.insert( pair<const Key, T>(k, v) );
>}
>
>multimap<int,double,less<int> > m;
>
>map_insert(m, 3, 5.0);
>
Yes, there are a number of reasonable approaches to work around the problem.
But what I can't understand is why the proposed standard is the way it
is. User workarounds tend to not be compatible with each other and defeat
some of the reasons for standardizing in the first place.
It is not as if this is a very subtle usage issue which is easy to miss
when designing the interface or in experimenting it before accepting it as
a part of the DWP. The awkwardness in using insert hits anyone trying
to use a STL multimap right off the bat, starting them immediately on
inventing a workaround. For projects on which I either have direct control
or significant input, I would not propose or accept a syntax which is
so awkward to use, especially when it does not require any great expertise
to come up with an easier to use and more efficient alternative syntax.
The people who designed and approved STL have impressive design and
implementation track records. And they chose the current syntax. I find
it hard to belive that all of them dropped the ball on this. I have been
waiting with bated breath for some one to tell me that I am wrong and to
point out the reason(s) for choosing the current syntax.
I am sure some of the people directly involved in either making the
proposal or moving it through the committee are reading this. I would
very much like to hear from some of them explaining the rationale for
the current choice.
If there is really no strong rationale to support the current insert
signature other than "it is the way it is", then I would hope that
the DWP is tweaked to overcome this shortcoming.
Regards,
- Ajay
--
Ajay Kamdar | Email: ajay@lehman.com | Standard Disclaimer
Lehman Brothers | Phone: (201) 524-5048 |
[ 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:
<41fhcu$kgp@engnews2.Eng.Sun.COM>Path:
arc1-ca.pugleaf.net!engnews2.Eng.Sun.COM!taumet!clamageReferences:
<9508170857.ZM22058@jabba> <411h8u$fi8@cyber.tn.tudelft.nl>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!engnews2.Eng.Sun.COM!taumet!clamage From: ajay@lehman.com (Ajay Kamdar) Newsgroups: comp.std.c++ Subject: Re: insert for map and multimap Date: 23 Aug 1995 15:27:26 GMT Organization: Lehman Brothers, Inc. Approved: clamage@eng.sun.com (comp.std.c++) Message-ID: <41fhcu$kgp@engnews2.Eng.Sun.COM> References: <9508170857.ZM22058@jabba> <411h8u$fi8@cyber.tn.tudelft.nl> NNTP-Posting-Host: taumet.eng.sun.com Content-Type: text/plain; charset="us-ascii" X-Lines: 83 Content-Length: 2478 Originator: clamage@taumet