Skip to content

Instantly share code, notes, and snippets.

@spullara
Created April 16, 2012 01:54
Show Gist options
  • Save spullara/2395968 to your computer and use it in GitHub Desktop.
Save spullara/2395968 to your computer and use it in GitHub Desktop.
Modern c++11
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <future>
using namespace std;
string flip(string s) {
reverse( begin(s), end(s) );
return s;
}
int main() {
vector<future<string>> v;
v.push_back( async([]{ return flip(" ,olleH"); }));
v.push_back( async([]{ return flip(".gnaL"); }));
v.push_back( async([]{ return flip("\n!TXEN"); }));
for (auto& e: v) {
cout << e.get();
}
}
@spullara
Copy link
Author

After installing gcc 4.7 with macports, I was able to compile this on my Mac with:

g++-mp-4.7 -std=c++11 -o main main.cpp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment