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

std::front_inserter

Defined in header <iterator>

?

?

template< class Container > std::front_insert_iterator<Container> front_inserter( Container& c );

?

?

front_inserter是构造std::front_insert_iterator用于集装箱c从参数类型推导出的类型。

参数

c

-

container that supports a push_front operation

返回值

std::front_insert_iterator,它可用于将元素添加到容器的开头。c...

可能的实施

模板<class容器>STD::前台[医]插入[医]迭代器<Container>前部[医]插入器%28容器和c%29{返回STD::前沿[医]插入[医]迭代器<Container>%28c%29;}

*。

二次

代码语言:javascript
复制
#include <iostream>
#include <deque>
#include <algorithm>
#include <iterator>
 
int main()
{
    std::deque<int> v{1,2,3,4,5,6,7,8,9,10};
    std::fill_n(std::front_inserter(v), 3, -1);
    for (int n : v)
        std::cout << n << ' ';
}

二次

产出:

二次

代码语言:javascript
复制
-1 -1 -1 1 2 3 4 5 6 7 8 9 10

二次

另见

front_insert_iterator

iterator adaptor for insertion at the front of a container (class template)

back_inserter

creates a std::back_insert_iterator of type inferred from the argument (function template)

inserter

creates a std::insert_iterator of type inferred from the argument (function template)

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

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

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com