Skip to content

Instantly share code, notes, and snippets.

@argv0
Last active December 27, 2015 10:09
Show Gist options
  • Save argv0/7309435 to your computer and use it in GitHub Desktop.
Save argv0/7309435 to your computer and use it in GitHub Desktop.
#include <map>
#include <vector>
#include <string>
#include <future>
#include <boost/lexical_cast.hpp>
using namespace std;
using boost::lexical_cast;
typedef map<string, string> object;
vector<object> objects = {
{{"user", "kyle"}, {"amount", "42"}},
{{"user", "kyle"}, {"amount", "1"}},
{{"user", "andy"}, {"amount", "0"}}
};
int main(void) {
cout << async([]() {
int sum;
for (object o: objects)
if (o["user"] == "kyle")
sum += lexical_cast<int>(o["amount"]);
return sum;
}).get() << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment