50-2.cpp
来自「effective stl 源代码 code」· C++ 代码 · 共 39 行
CPP
39 行
//
// Another example from ESTL Item 50
//
#include <string>
#include <iostream>
#include <vector>
#include "ESTLUtil.h"
int transmogrify(int x); // this function produces
// some new value from x
int transmogrify(int x)
{
return x + 10;
}
int main()
{
using namespace std;
using namespace ESTLUtils;
vector<int> values;
values.push_back(1);
values.push_back(10);
values.push_back(100);
values.push_back(37);
vector<int> results;
transform(values.begin(), values.end(), // this will attempt to
results.end(), // write beyond the
transmogrify); // end of results!
return 0;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?