Original Post
Hi, I'm currently writing a small XML parser in C++ to try to get back into coding, and I've run into a problem with std::wstring::const_iterator. At the start of my parsing routine, I load the entire text to be parsed into a wstring and initialize a wstring::const_iterator to the const_iterator returned by wstring's begin(). I then use this iterator for searching the wstring for tokens, reading text and so on. Problem is, the const_iterator doesn't know where the wstring ends, and happily tries to access memory it shouldn't resulting in my program dying with a segfault. My first reaction to this problem was that I should write a small wrapper class for the const_iterator, that checks the iterator's position against the length of the wstring and raise an exception (I figured exceptions would be a nice solution since checking every iterator increment for an error code would be pretty tedious) if the iterator goes out of bounds. However, since I'm not all that knowledgeable about the standard library I thought I should ask if there perhaps might already be something like this in there?