C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Iterator nach std::string::append

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ (German)
View previous topic :: View next topic  
Author Message
Steffen Rauh
Guest





PostPosted: Sat Oct 09, 2004 12:24 pm    Post subject: Iterator nach std::string::append Reply with quote



Wenn ich einen std::string verwende und mich zeichenweise über einen
Iterator durchhangel, bleibt der Iterator auch nach Anhänge-Operationen
gültig? Leider konnte ich in meiner STL-Doku dazu nichts finden.

std::string Test = "initialized data";
std::string::iterator iChar = Test.begin();
while (iChar != Test.end())
{
// do some work
// load other data and append them
std::string LoadedData = "dummy";
Test.append(LoadedData);

// what about:
Test = Test + LoadedData;

// do some other work
// advance with iterator
++iChar;
}

Wie sieht es bei Einfügeoperationen allgemein an beliebigen Stellen aus?
Und wenn iChar == Test.end() und dann Zeichen am Ende angehängt werden, gilt
dann iChar != Test.end() und iChar zeigt auf das erste angehängte Zeichen?

Ich könnte natürlich testen, wie sich mein Compiler in diesen Situationen
verhält, will aber standardkonform bleiben.

MfG,
Steffen Rauh

--
de.comp.lang.iso-c++ - Moderation: mailto:voyager+mod (AT) bud (DOT) prima.de
FAQ: http://www.voyager.prima.de/cpp/ mailto:voyager+send-faq (AT) bud (DOT) prima.de
Back to top
Markus Schaaf
Guest





PostPosted: Sun Oct 10, 2004 11:22 am    Post subject: Re: Iterator nach std::string::append Reply with quote



"Steffen Rauh" <steffen.rauh (AT) gmx (DOT) de> schrieb:

Quote:
Wenn ich einen std::string verwende und mich zeichenweise über einen
Iterator durchhangel, bleibt der Iterator auch nach Anhänge-Operationen
gültig?

Nach nichtkonstanten Funktionen (außer »operator[]«, »begin« etc.) und
»data«, »c_str« werden die Iteratoren ungültig.

Quote:
Leider konnte ich in meiner STL-Doku dazu nichts finden.

Was soll das sein? Schaust Du im Std oder einem richtigen Buch.

--
de.comp.lang.iso-c++ - Moderation: mailto:voyager+mod (AT) bud (DOT) prima.de
FAQ: http://www.voyager.prima.de/cpp/ mailto:voyager+send-faq (AT) bud (DOT) prima.de

Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ (German) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.