defercpp
README.md
defercpp
go-style defer function in c++
Example
#include <iostream>#include "defercpp.h"
int main(){ using namespace metafunc; auto print1 = []() { std::cout << 1 << std::endl; }; auto print3 = []() { std::cout << 3 << std::endl; };
defer(print1); defer([&]() { std::cout << 2 << std::endl; }); print3(); return 0;}
output:
3
2
1