From -5288063575163007528 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f78e5,dde8aef4d690b866 X-Google-Attributes: gidf78e5,public From: zdv176@zam229.zam.kfa-juelich.de (B.Mohr) Subject: Re: Problem with std::make_pair? Date: 1999/08/02 Message-ID: #1/1 X-Deja-AN: 507993556 X-Nntp-Posting-Host: zam229.zam.kfa-juelich.de Approved: stephen.clamage@sun.com (comp.std.c++) References: <37A4AEED.4CCE@wanadoo.fr> Organization: Forschungszentrum Juelich Newsgroups: comp.std.c++ Originator: clamage@taumet Valentin Bonnard writes: > But the problem here is _not_ the assignement to p, > as you seem to believe. It's just the > std::make_pair("B", 2) call in itself which doesn't > compile. > The real problem is with the fact that gcc tries to > assign _arrays_, and thus generates the error: > incompatible types in assignment of `const char[2]' to `char[2]' I understand this. But why did it work with g++/egcs before 2.95 and KCC before 3.4? I am sure KCC never allowed array assigment. > So your code is ill-formed, egcs is correct here. > (And it took me about half an hour to figure out.) 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. Thanks Bernd -- Bernd Mohr / Research Centre Juelich, ZAM, Germany / B.Mohr@fz-juelich.de [ 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 ]