safe_ptr is a smart pointer which manage a safe count in pointed
objects. SafeCountable provides the interface needed for safe_ptr
and assert the safe count is zero in destructor.
This permits to have pointers that guarantees their pointed object is
alive.
on_scope_end permits to register a functor to be called at scope
end (either exception thrown or normal scope end). this is usefull
for cleanup code that must be run.
usage:
auto cleaner = on_scope_end([]() { cleanup(); });
this helper permits to register a resource and cleanup function to keep
exception safety with C like resource. For exemple, to be sure that a
FILE* will be closed, you can use:
auto file = auto_raii(fopen("filename"), fclose);
file will auto cast to FILE* when needed, and will call fclose when
going out of scope.