shouldn't this read featureIt = features.erase( featureIt );  with ++featureIt in the if branch.