c++ - Unusual behaviour with std::list<myclass*>::iterator comparison -
i'm seeing unusual behavior when compare 2 iterators.
vector<list<myclass*>> vlwatchers(10); list<myclass*>::iterator itcurrent, itend; (int i(0); <= 9; ++i) { itcurrent = vlwatchers[i].begin(); itend = vlwatchers[i].end(); while (itcurrent != itend) { //code } } will cause liste iterators incompatible error on while() line, , appears happen when = 0, although of time.
upon further investigation after error called, itend , itcurrent both equal 0xcdcdcdcd. weird part when step != compare operator, "this" pointer becomes 0xcdcdcdcd. shouldn't 0xcdcdcdcd value that's stored in iterators, not address of iterators themselves? or there sort of iterator black magic iterator both stores value , value? part of larger project, error repeatable.
thank in advance help!
let's follow logic chain (assuming first few lines of for loop described):
itcurrent->this == 0xcdcdcdcd, therefore ...itcurrent == 0xcdcdcdcd, therefore ...vlwatchers[i].begin()returned0xcdcdcdcd, therefore ...vlwatchers[i]invalid, therefore perhaps ...i >= vlwatches.size(), orvlwatchersinvalid
i vote vlwatchers.size() == 0 somehow. can add check method detect case?
Comments
Post a Comment