Jean-Marc Lasgouttes wrote: > Juergen> Jean-Marc Lasgouttes wrote: // This is correct and always > Juergen> safe. // (See Meyer's Effective STL, Item 28.) return > Juergen> (++rit).base(); >>> Isn't it possible to fix this instead? I agree that the code is >>> not very clear... > > Juergen> I cannot fix it, because I don't understand it (and I > Juergen> certainly don't own Meyer's book). > > You are in the same situation as me, then. > > Could a reverse_iterator guru take a quick look? It has to be > trivial.
Actually, the bug is nothing to do with the internals of searchKeys which is where the reverse_iterator stuff is used. The bug is, indeed fixed by Jürgen's patch: vector<string>::const_iterator start = form_->bibkeys.begin(); int const sel = add_->availableLB->currentItem(); if (sel >= 0 && sel <= int(form_->bibkeys.size()-1)) start += sel; // Angus' annotation: if sel == 0, above then start == // form_->bibkeys.begin() // Find the NEXT instance... if (dir == biblio::FORWARD) start += 1; else start -= 1; Ok, bibkeys.begin() - 1 is 1 before the start. Isn't it undefined behaviour to do pretty well anything with such an iterator? -- Angus