From 1273946996299184909 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f78e5,dde8aef4d690b866 X-Google-Attributes: gidf78e5,public From: ark@research.att.com (Andrew Koenig) Subject: Re: Problem with std::make_pair? Date: 1999/08/02 Message-ID: #1/1 X-Deja-AN: 508082547 X-Nntp-Posting-Host: cat.research.att.com Approved: stephen.clamage@sun.com (comp.std.c++) References: <37A4AEED.4CCE@wanadoo.fr> X-UID: 0000000001 X-Status: $$$T Content-Type: text/plain; charset=us-ascii Organization: AT&T Research, Florham Park, NJ Mime-Version: 1.0 Newsgroups: comp.std.c++ Originator: clamage@taumet In article , B.Mohr wrote: >I believe you but there are dozens of books out there (e.g. Matt Austerns >great book on "Generic Programming and the STL"(?)) with the following >example (out of my head): > #include > #include > #include > int main() { > std::multimap phonebook; > phonebook.insert(std::make_pair("Joe", 134567)); /*1*/ > //... > } >They all worked fine but if your analysis is correct they are wrong >because line /*1*/ no longer compiles. I used this example in my STL >course; I am not sure whether I can explain my beginner programmers >why this example doesn't work. I came into the middle of this discussion, which may help explain why I don't understand the problem. make_pair("Joe", 134567) presumably yields an object of type pair (though many implementations will drop the const, which should be immaterial). phonebook.insert wants a pair, which can be constructed from a pair. So I see no reason why this example shouldn't work. What am I missing? -- Andrew Koenig, ark@research.att.com, http://www.research.att.com/info/ark [ comp.std.c++ is moderated. To submit articles, try just posting with ] [ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ] [ --- Please see the FAQ before posting. --- ] [ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]