Last active
December 27, 2015 10:09
-
-
Save argv0/7309435 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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