Wouldn't it be better to remove reference first and delete after that? It seems a bit wrong to have regions[idx] pointing to deleted region (but this should be only cosmetic problem)