Angus Leeming a écrit :
Abdelrazak Younes <[EMAIL PROTECTED]> writes:
Hello Lars,

If you want to simplify it even more, just erase the two iterator classes and put the following in ParagraphList.h instead; I believe the potential performance problems will go away once the use cases of ParagraphList uses direct access intead
of iterator access. And this will simplify the code in output*,
undo and CutAndPaste too.

ParagraphList::iterator
operator+(ParagraphList::iterator it, int pos) {
        return boost::next(it, pos);
}

[snip...]

I have tested it and it works correctly.

Sure, but there's no need not to do this only for the
Paragraph specialization of the RandomAccessList class template.

Because I think these operators are the wrong approach and we shouldn't allow that. So, as a short term solution, we provide these for ParagraphList so that the code compiles and then, we can fix the code to use the right operator instead, that is []. That solution would be plenty fast and wouldn't need some complicated iterator classes.

That just my opinion for what is worth.

I see no reason why this wouldn't work also:

template <typename Container>
typename RandomAccessList<Container>::iterator
operator+(typename RandomAccessList<Container>::iterator it, int pos) {
        return boost::next(it, pos);
}

Sure it should work but it's two line more ;-)

Abdel.


Angus



Reply via email to