首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

std::forward_list::splice_after

void splice_after( const_iterator pos, forward_list& other );

(1)

(since C++11)

void splice_after( const_iterator pos, forward_list&& other );

(1)

(since C++11)

void splice_after( const_iterator pos, forward_list& other, const_iterator it );

(2)

(since C++11)

void splice_after( const_iterator pos, forward_list&& other, const_iterator it );

(2)

(since C++11)

void splice_after( const_iterator pos, forward_list& other, const_iterator first, const_iterator last );

(3)

(since C++11)

void splice_after( const_iterator pos, forward_list&& other, const_iterator first, const_iterator last );

(3)

(since C++11)

从另一个移动元素forward_list*this...

没有复制任何元素。pos中的有效迭代器。*this或者是before_begin()迭代器。如果get_allocator() != other.get_allocator()没有迭代器或引用失效,移动元素的迭代器现在引用到*this,而不是进入other...

1%29移动所有元素other*this。元素插入到pos.集装箱other手术后变为空。如果this == &other

2%29移动迭代器指向的元素如下itother*thispos.没有任何效果pos==it或者如果pos==++it...

3%29移动范围内的元素(first, last)other*this。元素插入到pos.指向的元素first不会动。如果pos是范围内的迭代器。(first,last)...

参数

pos

-

element after which the content will be inserted

other

-

another container to move the content from

it

-

iterator preceding the iterator to the element to move from other to *this

first, last

-

the range of elements to move from other to *this

返回值

%280%29

复杂性

1%29线性other

2%29常数

3%29线性std::distance(first, last)

演示第三种拼接形式中打开间隔%281,最后%29的含义。[医]在%28%29之后:L1的第一个元素没有移动。

二次

代码语言:javascript
复制
#include <iostream>
#include <forward_list>
 
int main()
{
    std::forward_list<int> l1 = {1,2,3,4,5};
    std::forward_list<int> l2 = {10,11,12};
 
    l2.splice_after(l2.cbegin(), l1, l1.cbegin(), l1.cend());
    // not equivalent to l2.splice_after(l2.cbegin(), l1);
 
    for(int n : l1)
        std::cout << n << ' ';
    std::cout << '\n';
 
    for(int n : l2)
        std::cout << n << ' ';
    std::cout << '\n';
}

二次

产出:

二次

代码语言:javascript
复制
1
10 2 3 4 5 11 12

二次

另见

merge

merges two sorted lists (public member function)

removeremove_if

removes elements satisfying specific criteria (public member function)

代码语言:txt
复制
 © cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

扫码关注腾讯云开发者

领取腾讯云代金券