相关疑难解决方法(0)

用于std :: set的std :: back_inserter?

我想这是一个简单的问题.我需要做这样的事情:

std::set<int> s1, s2;
s1 = getAnExcitingSet();
std::transform(s1.begin(), s1.end(), std::back_inserter(s2), ExcitingUnaryFunctor());
Run Code Online (Sandbox Code Playgroud)

当然,std::back_inserter因为没有,所以不起作用push_back. std::inserter还需要一个迭代器?我没有用过,std::inserter所以我不知道该怎么做.

有没有人有想法?


当然,我的另一个选择是使用向量s2,然后稍后对其进行排序.也许那更好?

c++ algorithm stl

85
推荐指数
1
解决办法
2万
查看次数

标签 统计

algorithm ×1

c++ ×1

stl ×1