Le 09/12/2015 06:54, Scott Kostyshak a écrit :
Regarding the following code:
-----
void Text::selectWord(Cursor & cur, word_location loc)
{
LBUFERR(this == cur.text());
CursorSlice from = cur.top();
CursorSlice to = cur.top();
getWord(from, to, loc);
-----
It is not easy to know whether "to" and "from" are equal to each other because
cur.top() might return something different the second time. For readability
purposes, I would prefer either
I do not really see why this confuses you actually. Note anyway that the
value of 'to' is irrelevant, since it is initialized to be equal to 'to'
at the start of getWord. The best solution is maybe to change the
signature of getWord to be
std::pair<pos_type, pos_type> getWord(CursorSlice const & cs,
word_location loc) const
I set the return value to a pos_type pair because it seems to me that
the pit is always cur.pit(), but I might be wrong.
JMarc