eav is a C++20 header-only library for error handling, inspired by the philosophies of Rust, Go, and functional programming.
The library provides a Result<T, E> & Option<T> types that help to process errors as values explicitly, without a hidden exception control flow, while maintaining code purity using pipeline syntax in a style typical of functional programming.
eav-lib provides ability to chain complex logic into a single, readable flow. With eav-lib, you compose logic using the | (pipe) operator.
MapOk: transforms the successful value;AndThen: chains another operation that might fail (monadicbind);Filter: validates a value and converts it to an error if criteria aren't met;MapErr: converts error types;OrElse: recovers from an error or provides a fallback value;
Map: transforms the value if present;AndThen: chains another operation returning anOption;Filter: keeps the value only if it satisfies a predicate;OrElse: provides a fallbackOptionif the current one isNone;
Since the eav is header-only, you can simply copy the eav folder to your project or use CMake's FetchContent:
include(FetchContent)
FetchContent_Declare(
eav
GIT_REPOSITORY https://github.com/t1mn0/eav.git
GIT_TAG main
)
FetchContent_MakeAvailable(eav)
target_link_libraries(your_project PRIVATE eav)Philosophy and design principles:
Combinators and functional pipeline ideas: