Skip to content

Instantly share code, notes, and snippets.

@devramx
Created May 24, 2018 04:29
Show Gist options
  • Save devramx/5d18ae99dad79daa55d787ad079815cb to your computer and use it in GitHub Desktop.
Save devramx/5d18ae99dad79daa55d787ad079815cb to your computer and use it in GitHub Desktop.
C++ increment closure
#include <functional>
auto inc() -> std::function<int(void)> {
int i =0;
return [i]() mutable ->int{
return ++i;
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment