c++ - forward_list::splice_after( const_iterator pos, forward_list& other, const_iterator i ) 功能

标签 c++ list c++11 splice forward-list

我正在阅读有关此功能工作方式的不同解释。

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/

相关文章:

c++ - 将复制返回的值分配给引用

C++ 稀疏矩阵容器

c++ - 编译cpp源仅在c支持下运行

c++ - 将迭代器用于 STL 列表数组的语法

python计算字符串列表中的单词数

python - 使用递归的嵌套列表的最高值和最低值

c++ - 将对象插入列表,C++

c++ - 使用删除器初始化 std::unique_ptr

c++ - boost::任意数字

c++ - 使用 shared_from_this 时出现 std::bad_weak_ptr 异常