diff options
author | Nicolas "Pixel" Noble <pixel@nobis-crew.org> | 2013-12-25 01:14:38 -0800 |
---|---|---|
committer | Nicolas "Pixel" Noble <pixel@nobis-crew.org> | 2013-12-25 01:14:38 -0800 |
commit | 24eca6aa60f0848ad671b1fe11351d6e911b14e0 (patch) | |
tree | ee3ebc7ed6b53a538a6deaa5716f26fd57c01325 | |
parent | f1ad2cad1a6baca25700fd520f6fc3e91c319680 (diff) |
Adding ScopedLambdas.
-rw-r--r-- | includes/Exceptions.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/includes/Exceptions.h b/includes/Exceptions.h index 47bd1f5..799bfb6 100644 --- a/includes/Exceptions.h +++ b/includes/Exceptions.h @@ -2,6 +2,7 @@ #include <stdarg.h> #include <typeinfo> +#include <functional> #ifndef _MSC_VER #include <cxxabi.h> @@ -174,3 +175,11 @@ ClassName::ClassName(T * ptr) { msg.set("UnitTest Assert " #c " failed at %s:%i", __FILE__, __LINE__); \ Balau::TestHelper(msg); \ } + +class ScopedLambda { + public: + ScopedLambda(std::function<void()> l) : m_l(l) { } + ~ScopedLambda() { m_l(); } + private: + std::function<void()> m_l; +}; |