
Removing items from STL map without deletion?
*iter "gets" without deleting.
erase(iter) deletes without getting.
The following should do what you want.....
// WARNING untested code ahead
template <typename T>
T get(typename T::iterator iter)
{
T t = *iter;
erase(iter);
return (t);
}
--
Truth,
James [MVP]
http://www.NJTheater.Com -and-
http://www.NJTheater.Com/JamesCurran
Quote:
>I may be completely confused here but I only see methods for
>erasing(deleting) contained objects. There seem to to be no way to remove
>objects without deletion. The "remove" algorigthm makes even less sense.
>I have used Rogue Wave before and most of its collection classes provide a
>get() method to pop the stored object out of the collection. How can one
>accomplish that with STL map or set
>Zia Bhatti
begin 666 James M. Curran.vcf
M4DLZ.SLQ."!*;VAN(%-T+"!3=6ET92 R0CM";&]O;69I96QD.TY*.S W,# S
M+34Q-#D-"DQ!0D5,.U=/4DL[14Y#3T1)3D<]455/5$5$+5!224Y404),13HQ
M."!*;VAN(%-T+"!3=6ET92 R0CTP1#TP04)L;V]M9FEE;&0L($Y*(# W,# S
M+34Q-#D-"E523#IH='1P.B\O=W=W+DY*5&AE871E<BYC;VTO2F%M97-#=7)R
M86X-"E523#IH='1P.B\O=W=W+DY*5&AE871E<BYC;VT-"D5-04E,.U!2148[
M24Y415).150Z2F%M97-#=7)R86Y 0V]M<'5397)V92YC;VT-"E)%5CHQ.3DX
`
end