Skip to content

Latest commit

 

History

History
29 lines (23 loc) · 558 Bytes

README.md

File metadata and controls

29 lines (23 loc) · 558 Bytes

logic_guards

I'm tired of seeing poorly written scope exits in many projects, so i create header only library with scope_exit and scope_failure designed to be copy-pasted into any other project

Usage:

auto usage_example1() {
  T* p = new T;
  on_scope_exit {
    delete p;
  };
  // ...
}

T* usage_example2() {
  T* p = new T;
  on_scope_failure(free_memory) {
    delete p;
  };
  // ...

  // here we show that 'dangerous' operations are completed
  // and we dont need free memory on exit
  free_memory.no_longer_needed();
  return p;
}