Last active
March 22, 2017 23:11
-
-
Save hadronized/e93463fb3e7cfe9bd6c67e56ccbace5a to your computer and use it in GitHub Desktop.
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
// g++ main.cpp -std=c++17 -W -Wall -pedantic | |
#include <cstdlib> | |
#include <cstdint> | |
#include <functional> | |
auto foo() -> std::function<void ()> { | |
int32_t a = 317; | |
return [&a]() { | |
printf("%d", a); | |
}; | |
} | |
auto foo_move() -> std::function<void ()> { | |
int32_t a = 317; | |
return [&a]() { | |
printf("%d", a); | |
}; | |
} | |
int main() { | |
auto closure = foo(); | |
closure(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment