nmarwen / state_saver

State Saver C++

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

State Saver C++

  _____ _        _          _____                         _____
 / ____| |      | |        / ____|                       / ____|_     _
| (___ | |_ __ _| |_ ___  | (___   __ ___   _____ _ __  | |   _| |_ _| |_
 \___ \| __/ _` | __/ _ \  \___ \ / _` \ \ / / _ \ '__| | |  |_   _|_   _|
 ____) | || (_| | ||  __/  ____) | (_| |\ V /  __/ |    | |____|_|   |_|
|_____/ \__\__,_|\__\___| |_____/ \__,_| \_/ \___|_|     \_____|
Branch Linux/OSX Windows License Codacy
master Build Status Build status License Codacy Badge

StateSaver - saves the origin variable value and restores on scope exit, undoes any changes that could occure to the object.

Features

  • Simple syntax
  • C++11
  • Header-only
  • Dependency-free

Examples

void Foo(A& a)
  STATE_SAVER(a);
  ... // Alter state from non-const functions.
  ... // Other code.
  // Original state automatically restored.
}

Integration

You should add required file state_saver.hpp and switch to C++11.

Compiler compatibility

  • GCC
  • Clang
  • MSVC

Licensed under the MIT License

About

State Saver C++

License:MIT License


Languages

Language:C++ 94.7%Language:CMake 5.3%