我正在阅读有关此功能工作方式的不同解释。
cplusplus.com说这个函数应该“直接在 i 之后移动元素”。
然而cppreference.com表示它拼接元素 AT i。
MSvisual studio 同意 cplusplus.com。但是,实际上正确的行为是什么?我倾向于认为“在 i 之后”移动更合乎逻辑(& 不需要 N 时间来找到前面的节点)。
(PS:没有 forward-list 标签?)
最佳答案
23.3.4.6
void splice_after(const_iterator position, forward_list& x, const_iterator i);
void splice_after(const_iterator position, forward_list&& x, const_iterator i);
Effects: Inserts the element following i into *this, following position, and removes it from x. The result is unchanged if position == i or position == ++i. Pointers and references to *i continue to refer to the same element but as a member of *this. Iterators to *i (including i itself) continue to refer to the same element, but now behave as iterators into *this, not into x.
关于c++ - forward_list::splice_after( const_iterator pos, forward_list& other, const_iterator i ) 功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13822540/