Skip to content

Instantly share code, notes, and snippets.

@Rydgel
Created July 26, 2018 08:30
Show Gist options
  • Save Rydgel/9ed8c54699096948779d7d9e0e5f5bee to your computer and use it in GitHub Desktop.
Save Rydgel/9ed8c54699096948779d7d9e0e5f5bee to your computer and use it in GitHub Desktop.
struct A { char* name = "A"; };
struct B { char* name = "B"; };
auto dispatch = [](int n, auto continuation) {
switch (n) {
case 0: return continuation(A{});
case 1: return continuation(B{});
}
// throw or something here
};
auto f() {
return dispatch(1, [](auto t) { return t.name; });
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment