Last active
December 28, 2015 18:39
-
-
Save michaelcontento/f2f470a53ac4dc541729 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
std::function<void()> once(const std::function<void()>& callback) | |
{ | |
return [&callback]() { | |
static bool called = false; | |
if (!called) { | |
called = true; | |
callback(); | |
} | |
}; | |
} | |
bool MyClass::init() | |
{ | |
static auto wuhu = once([](){ log("WUHU!"); }); | |
wuhu(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment