Skip to content

Instantly share code, notes, and snippets.

@skyrpex
Created July 4, 2017 16:04
Show Gist options
  • Save skyrpex/7fcc421104910de1dfd76d4b8b60590d to your computer and use it in GitHub Desktop.
Save skyrpex/7fcc421104910de1dfd76d4b8b60590d to your computer and use it in GitHub Desktop.
boost::optional<int> f1(int a);
boost::optional<int> f2(int b, int c);
boost::optional<int> f3(int d);
boost::optional<int> f4(int e);
boost::optional<int> result = chain(
[] { return f1(3); },
[] { return f1(4); }
).then(
[] (int b, int c) { return f2(b, c); }
).then(
[] (int d) { return f3(d); }
).then(
[] (int e) { return f3(e); }
).run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment