|
wwa-scope-action 1.0.0
Scope guard utilities for managing exit actions in C++
|
This project provides a set of scope guard utilities for managing exit actions in C++. These utilities ensure that specified actions are executed when a scope is exited, regardless of how the exit occurs. The scope guards include:
exit_action: Executes an action when the scope is exited.fail_action: Executes an action when the scope is exited due to an exception.success_action: Executes an action when the scope is exited normally.These utilities are useful for ensuring that resources are properly released or actions are taken when a scope is exited.
The documentation is available at https://sjinks.github.io/scope-action-cpp/.
exit_actionA scope guard that calls its exit function on destruction, when a scope is exited.
fail_actionA scope guard that calls its exit function when a scope is exited via an exception.
success_actionA scope guard that calls its exit function when a scope is exited normally.
| Option | Description | Default |
|---|---|---|
BUILD_TESTS | Build tests | ON |
BUILD_EXAMPLES | Build examples | ON |
BUILD_DOCS | Build documentation | ON |
BUILD_INTERNAL_DOCS | Build internal documentation | OFF |
ENABLE_MAINTAINER_MODE | Maintainer mode (enable more compiler warnings, treat warnings as errors) | OFF |
USE_CLANG_TIDY | Use clang-tidy during build | OFF |
The BUILD_DOCS (public API documentation) and BUILD_INTERNAL_DOCS (public and private API documentation) require Doxygen and, optionally, dot (a part of Graphviz).
The USE_CLANG_TIDY option requires clang-tidy.
| Build Type | Description |
|---|---|
Debug | Build with debugging information and no optimization. |
Release | Build with optimization for maximum performance and no debugging information. |
RelWithDebInfo | Build with optimization and include debugging information. |
MinSizeRel | Build with optimization for minimum size. |
ASAN | Build with AddressSanitizer enabled for detecting memory errors. |
LSAN | Build with LeakSanitizer enabled for detecting memory leaks. |
UBSAN | Build with UndefinedBehaviorSanitizer enabled for detecting undefined behavior. |
TSAN | Build with ThreadSanitizer enabled for detecting data races. |
Coverage | Build with code coverage analysis enabled. |
ASAN, LSAN, UBSAN, TSAN, and Coverage builds are only supported with GCC or clang.
Coverage build requires gcov (GCC) or llvm-gcov (clang) and gcovr.
To run the tests, use the following command:
or run the following binary:
The test binary uses Google Test library. Its behavior can be controlled via environment variables and/or command line flags.
Run test_scope_action --help for the list of available options.
This project is licensed under the MIT License.
This project is inspired by the scope guard utilities from the (experimental) Version 3 of the C++ Extensions for Library Fundamentals and the Guidelines Support Library (GSL).