Skip to content

Instantly share code, notes, and snippets.

@YusukeSuzuki
Forked from anonymous/transform
Created December 24, 2012 06:07
Show Gist options
  • Select an option

  • Save YusukeSuzuki/4367966 to your computer and use it in GitHub Desktop.

Select an option

Save YusukeSuzuki/4367966 to your computer and use it in GitHub Desktop.
#include <algorithm>
#include <vector>
#include <iostream>
int
main(int argc, char* argv[])
{
using namespace std;
vector<double> v1 = {1.1,2.2,3.3};
vector<int> v2(v1.size());
transform(
v1.begin(), v1.end(), v2.begin(),
[](decltype(v1)::value_type a) -> decltype(v2)::value_type { return a; });
for(auto i : v2)
{
cout << i << endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment