1
1
Fork 0
mirror of https://github.com/trafi/maybe-result-cpp synced 2024-04-27 04:05:05 +02:00
Maybe Result implementation for C++
Go to file
Olegas Murasko 99b8aad78b
Adding CODEOWNERS
2019-10-22 15:12:44 +03:00
dev Include optional tarbal for tests. 2016-09-22 14:28:40 +03:00
examples Links to docs. 2016-07-10 18:16:26 +03:00
src Use std::move to move value in move accessor. 2016-09-23 13:58:51 +03:00
tests Fix return type in tests. 2016-09-22 15:54:52 +03:00
.clang-format Move accessors, additional tests and docs. 2016-07-08 13:32:08 +03:00
.gitignore Add documentation generation. 2016-07-10 17:11:04 +03:00
.travis.yml Another way to install doxygen. 2016-07-10 17:30:15 +03:00
.whitesource Add .whitesource configuration file 2019-10-18 13:57:53 +00:00
CMakeLists.txt Reduxe CMake required version to 3.0. 2016-07-08 15:26:55 +03:00
CODEOWNERS Adding CODEOWNERS 2019-10-22 15:12:44 +03:00
Doxyfile Links to docs. 2016-07-10 18:16:26 +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 Use markdown status. 2016-07-10 18:18:02 +03:00
export_doc.sh Another way to install doxygen. 2016-07-10 17:30:15 +03:00

Maybe Result

Build Status

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 (4.9) or CLANG (3.7).

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

Running tests

Library requires std::experimental::optional implementation, location of which can be specified with -DEXPERIMENTAL_OPTIONAL_INCLUDE flag:

cmake -DEXPERIMENTAL_OPTIONAL_INCLUDE=../path/to/optional .
make tests && ./tests/tests

There is a script that does this automatically:

./dev/run-tests.sh

In addition to this, you can run tests on all supported compilers using docker:

./dev/docker-run-tests.sh

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.