From -5825522570252044481
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: f78e5,c2bd1286392a0f79
X-Google-Attributes: gidf78e5,public
From: Robert Klemme <babelfish@gmx.net>
Subject: Re: std::vector construction question
Date: 2000/03/01
Message-ID: <38BBCCDE.C337B832@gmx.net>#1/1
X-Deja-AN: 591319958
Approved: Fergus Henderson <fjh@cs.mu.oz.au>, moderator of comp.std.c++
References: <B4E15DA0-654E8@192.109.102.124>
X-Accept-Language: de
X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f
X-Complaints-To: abuse@demon.net
X-Mail2News-Path: news.demon.net!mulga.cs.mu.oz.au
X-Trace: mail2news.demon.co.uk 951835775 mail2news:13096 mail2news mail2news.demon.co.uk
Organization: myview technologies
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
Reply-To: robert.klemme@myview.de
NNTP-Posting-Date: 29 Feb 2000 13:42:58 GMT
X-MIME-Autoconverted: from 8bit to quoted-printable by mumnunah.cs.mu.OZ.AU id AAA20542
Newsgroups: comp.std.c++


hi,

your main problem seems to be, that the iterator of a map does not yield
the elment on deref.  instead you would have to use somthing like
iter->first (for the key) or iter->second.  since your compiler cannot
read your mind, it is not possible the way you suggested.  you have to
copy them manually.


Gabor Greif schrieb:
> 
> I have the problem of moving data from a std::map to a std::vector to be
> able to sort it.
> 
> #include <map>
> #include <vector>
> #include <string>
> using namespace std;
> 
> ...
> 
> void processmap(const map<string, int>& table)
> {
>         vector<const string, int> v(table.begin(), table.end());
>         sort(v.begin(), v.end(), SomePredicate);
> }
> 
> I understand that the element type for both containers (pair<const string,
> int>) does not have a compiler generated assignment operator.

afaik this is wrong: there is an assignment for pair<A,B> for any A and
B that support operator=.

> The reason why I am posting is that of two compilers we use here one
> accepted the above example, the second choked on the vector constructor
> right from the start. A rewrite using push_back revealed the absence of the
> assignment operator.

strange...

	robert

-- 
Robert Klemme
Software Engineer
-------------------------------------------------------------
myview technologies GmbH & Co. KG
Riemekestra�e 160 ~ D-33106 Paderborn ~ Germany
E-Mail: mailto:robert.klemme@myview.de
Telefon: +49/5251/69090-321 ~ Fax: +49/5251/69090-399
-------------------------------------------------------------

---
[ 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              ]




