PageIterator and PageRemove

I'm looking at removing multiple pages with page iterator. All the examples seem to get a new iterator object before each page removal as such...

pdftron::PDF::PageIterator it;
  while (firstPage<=lastPage) {
    it = doc->GetPageIterator(firstPage+1);

Isn't this a little wasteful. Isn't it possible to get a PageIterator just once and then use .Next (or not as the case may be if the iterator is pointing to the next page anyway after the existing page has been removed)? I have tried this approach but it throws an error, it must surely be possible.

While it is an iterator can remain valid after modification of the container, this is not true for all container iterators, and is not currently true for our page iterator.

We will look to improve this in the future, but currently you would need to get a new iterator.

// remove every 2nd page (odd pages) int page_num = in_doc.GetPageCount(); PageIterator itr; while (page_num>=1) { itr = in_doc.PageFind(page_num); in_doc.PageRemove(itr); page_num -= 2; }