Andre Poenitz <[EMAIL PROTECTED]> writes: | On Sun, Feb 06, 2005 at 03:55:16AM +0100, Lars Gullik Bjønnes wrote: >> >> void leaveInset(LCursor & cur, InsetBase const & in) >> { >> for (size_t i = 0; i != cur.depth(); ++i) { >> if (&cur[i].inset() == &in) { >> cur.resize(i); >> return; >> } >> } >> } >> >> >> Used here f.ex. >> >> And LCursor::resize really is std::vector<CursorSlice>::resize, I am >> perplexed... >> >> When is it ever interesting to resize a LCursor? > | When something serious happened to the structure above the current | cursor level. > | Say, you are in a frac in a sqrt in an array and call 'delete row'. | The array will handle the request and completely destroy the sqrt and | frac, so the cursor must be moved out to some safe position, in this | case into the array. | >> It seems to me that this is just a very funny way of writing erase. > | It sort of is, but the criterion how many items are erased is given by | the inset argument.
But would be much clearer to use something like cur.erase(cur.begin() + i, cur.end()); using resize for this almost count as obfuscation. I think it could even be written like cur.erase(find_if(cur.begin(), cur.end(), findInset(in)), cur.end()); i.e. iterator it = find_if(cur.begin(), cur.end(), findInset(in)); if (it != cur.end()) cur.erase(it, cur.end); -- Lgb