Skip to content

Instantly share code, notes, and snippets.

@shintakezou
Created April 24, 2012 16:40
Show Gist options
  • Save shintakezou/2481327 to your computer and use it in GitHub Desktop.
Save shintakezou/2481327 to your computer and use it in GitHub Desktop.
"Array map" in C++11
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
vector<string> vet {"hello", "world", "take", "the", "moon"};
vector<string>::iterator it;
transform(vet.begin(), vet.end(), vet.begin(),
[](const string &s) -> string { return string(s.rbegin(), s.rend()); });
for (it = vet.begin(); it != vet.end(); it++)
cout << *it << " ";
cout << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment