Pavel Sanda wrote: >> Yep, seems perfect, and it should be faster than the other version. Note > > unfortunately both std::distance and fun below hangs when counting inside > selection. anybody idea whats going wrong?
I think so. If the two ParIterators point to the same paragraph, the loop shouldn't be entered (so there is an off by one error arguably). Unfortunately operator!=(ParIterator &, ParIterator &) is implemented with operator!=(DocIterator &, DocIterator &) that gives false if the positions are different, even if the pars are the same. So ultimately it's a bug in operator!=(ParIterator &, ParIterator &) I'd say (nevertheless, I would be reluctant to change it, because I fear that some part of the code could rely on this "bug"). Alternatively one could reset positions to 0 (probably the best would be in the conversion DocIterator->ParIterator. A/