Created
May 24, 2018 04:29
-
-
Save devramx/5d18ae99dad79daa55d787ad079815cb to your computer and use it in GitHub Desktop.
C++ increment closure
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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