Created
October 10, 2013 18:42
-
-
Save randvoorhies/6923348 to your computer and use it in GitHub Desktop.
Deadman gist
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
//! A deadman switch that will execute it's constructor parameter on destruction unless disarm()'d | |
struct deadman | |
{ | |
deadman(std::function<void()> boom) : boom_(boom) {} | |
~deadman() { boom_(); } | |
void disarm() { boom_ = [](){}; } | |
std::function<void()> boom_; | |
}; |
Author
randvoorhies
commented
Oct 10, 2013
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment