From 2105703410194115690
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: <zdv176.933595065@zam229>#1/1
X-Deja-AN: 508033309
Approved: Valentin Bonnard <bonnard@clipper.ens.fr>
References: <zdv176.933510565@zam229> <slrn7q9il3.9hq.sbnaran@localhost.localdomain>
X-Original-Date: 2 Aug 99 11:57:45 GMT
X-Authentication-Warning: backdraft.briar.org: smap set sender to <news@zam201.zam.kfa-juelich.de> using -f
Organization: Forschungszentrum Juelich
X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBVAwUAN6Xak6wEuYhIxRhxAQFNhwH/ekxCj1s+a4USSEIB8DAkjkkzSHP9wS5B QktlMSbcmLv3ElRBfnmf5JlIj1wTIAc+9HbwT7SktXOG7hPlYMXBvQ== =jeJQ
Newsgroups: comp.std.c++

sbnaran@localhost.localdomain (Siemel Naran) writes:
>>    std::pair<std::string, int> p("A", 1);        /*1*/
>>    p = std::make_pair("B", 2);                   /*2*/

>If your compiler allows array assignment (and KCC and EDG compilers do
>not), then the above code compiles but it is inefficient.

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.

>How about this:
>     typedef std::pair<std::string, int> Pair;
>     Pair p("A",1);
>     p=Pair("B",2);

I know there are all kind of work-arounds (using char* instead of string,
your soultion above and dozens others). But I still think my
line above marked /*1*/ is the most "natural" (something which
you find in all books / websites about STL and therefore think first).
Also, make_pair works this way with almost every type, but it looks like
not with std::string). 

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              ]



