Skip to content

Instantly share code, notes, and snippets.

@kalman5
Last active January 25, 2020 08:42
Show Gist options
  • Select an option

  • Save kalman5/8cf9f0dd61c968aefa0c13525a559b04 to your computer and use it in GitHub Desktop.

Select an option

Save kalman5/8cf9f0dd61c968aefa0c13525a559b04 to your computer and use it in GitHub Desktop.
template <typename F>
void PrePost(F&& f) {
std::cout << "pre\n";
f();
std::cout << "post\n";
}
int main() {
double a = 1.1;
double b = 2.2;
double c = 3.3;
PrePost([&a, &b, c]() mutable {
c = 4;
std::cout << a << " " << b << " " << c << "\n";
});
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment