From -2612083075178791882
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,66d20309909372f6,start
X-Google-Attributes: gidf78e5,public
From: "NJ Biggs" <njb1441@ggr.co.uk>
Subject: STL and set_union algorithm question? (newbie to STL!)
Date: 1998/04/04
Message-ID: <6g2te9$a7n$1@ukwsv3.ggr.co.uk>#1/1
X-Deja-AN: 340880883
Approved: Fergus Henderson <fjh@cs.mu.oz.au>
X-Original-Date: Fri, 3 Apr 1998 15:55:57 +0100
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.2106.4
X-Complaints-To: usenet@ggr.co.uk
X-Trace: ukwsv3.ggr.co.uk 891615497 10487 (None) 147.184.190.106
Organization: Glaxo Wellcome
X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBFAgUANSaGa+EDnX0m9pzZAQEE2AF8DX3Rk+H1rjOC8DQLCFJ5qWk1zdRdFTn9 QNteFmNBw5BxqcUe7+V6xuVZunef/Xho =Dc+N
Newsgroups: comp.std.c++


I am new to STL and am after a little help.

Can anyone please post a short example of using the set_union algorithm on
two set<int> objects that places the result in a third set<int>.

Sort of...
set<int> s1;
set<int> s2;
set<int> result;

set_union(s1.begin(), s1.end(), s2.begin(), s2.end(), result.end());

My compiler refuses to compile this due to the result.end() iterator being
returned as a const_iterator.

So far I have worked around this by putting the result into a vector<int>
and afterwards I coerce the results back into a set<int> again. This seems
like a kludge to me so I thought I would try to get some guru type guidance
here?

So just how do I go about using set_union with set<int> objects?
--
Nicholas J Biggs
Principle Analyst Programmer
Work: mailto:njb1441@ggr.co.uk
Home: mailto:snark@pawn.demon.co.uk
--
---
[ 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              ]



