Skip to content

Instantly share code, notes, and snippets.

@vinipsmaker
Created January 31, 2014 19:33
Show Gist options
  • Save vinipsmaker/8741321 to your computer and use it in GitHub Desktop.
Save vinipsmaker/8741321 to your computer and use it in GitHub Desktop.
// taken from http://isocpp.org/files/papers/N3858.pdf
future<int> f(shared_ptr<stream> str)
{
shared_ptr<vector<char>> buf = ...;
return str->read(512, buf)
.then([](future<int> op) { // lambda 1
return op.get() + 11;
}
);
}
future<void> g()
{
shared_ptr<stream> s = ...;
return f(s).then([s](future<int> op) { // lambda 2
s->close();
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment