1
1
mirror of https://github.com/trafi/maybe-result-cpp synced 2024-11-26 04:26:06 +01:00
Maybe Result implementation for C++
Go to file
Nerijus Arlauskas 6df8f76748 Initial files.
2016-07-05 22:59:12 +03:00
src Initial files. 2016-07-05 22:59:12 +03:00
tests Initial files. 2016-07-05 22:59:12 +03:00
.clang-format Initial files. 2016-07-05 22:59:12 +03:00
.gitignore Initial files. 2016-07-05 22:59:12 +03:00
CMakeLists.txt Initial files. 2016-07-05 22:59:12 +03:00
LICENSE-APACHE Initial files. 2016-07-05 22:59:12 +03:00
LICENSE-MIT Initial files. 2016-07-05 22:59:12 +03:00
README.md Initial files. 2016-07-05 22:59:12 +03:00

Maybe Result

Maybe Result is a return value wrapper that can contain either a value T or error E. It borrows ideas heavily from the C++17's std::experimental::optional, Rust's std::result and the std::expected that was proposed but not yet accepted for C++17.

How is it different from std::experimental::optional?

Has a value for error instead of nullopt.

How is it different from std::expected?

It does not require the error to be an exception, and does not fall back to exceptions. All values must be checked, similar to std::experimental::optional.

Setting up

This is header-only library. We recommend to add src to included directories, so that the include would be:

#include <maybe/result.hpp>

A C++ compiler shat supports C++14 is required. You can use -std=c++14 flag for sufficiently recent versions of GCC or CLANG.

Warning! Library is highly experimental and is not guaranteed to work.

Running tests

cmake .
make tests && ./tests/tests

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.