#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
vector<int> ivec = { 1, 2, 3, 4 };
transform(ivec.begin(), ivec.end(), ivec.begin(),
[](int v){return v*v;});
for_each(ivec.begin(), ivec.end(), [](int v){cout << v << " ";});
return 0;
}
STL transform() demo
最新推荐文章于 2022-02-03 16:08:46 发布