std::advance
template <class InputIterator, class Distance>
void advance (InputIterator& i, Distance n);
If i is a Random Access Iterator, the function uses once operator+ or operator-, otherwise, the function uses repeatedly the increase or decrease operator ( operator++ or operator--) until n elements have been advanced.
void advance (InputIterator& i, Distance n);
Advance iterator
Advances the iterator i by n elements.If i is a Random Access Iterator, the function uses once operator+ or operator-, otherwise, the function uses repeatedly the increase or decrease operator ( operator++ or operator--) until n elements have been advanced.
bug现象为对链表中的某个元素移动位置后,日志定位发现链表顺序出现错乱。
原因是std::advance函数不能保证在参数n超出元素个数后自动结束。
所以在使用该函数时,需要对参数n进行限制。