OI-Wiki上关于erase的介绍是
erase() 删除某个迭代器或者区间的元素,返回最后被删除的迭代器。复杂度与 insert 一致。
cplusplus上的对返回值的介绍是
An iterator pointing to the new location of the element that followed the last element erased by the function call. This is the container end if the operation erased the last element in the sequence.
经过测试发现后者更符合一些,即调用erase函数删除迭代器的内容后会返回删除元素的下一个位置的迭代器,并且会自动让当前迭代器指向下一个位置
test.erase(i)
i=test.erase(i)
经过测试以上两种形式的结果是一样的,执行后test容器里迭代器i所指的元素被删掉,i指向下一个位置。
另外,vector的end()函数返回的是指向容器末尾元素的下一个位置而不是末尾元素。