Giter Site home page Giter Site logo

maybe-result-cpp's Introduction

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.

maybe-result-cpp's People

Contributors

nercury avatar olegas-murasko-trafi avatar mend-bolt-for-github[bot] avatar

Stargazers

Ribhi avatar Arstan avatar Berkus Decker avatar  avatar Silvan Wegmann avatar Gleb Dolgich avatar Andrey Upadyshev avatar

Watchers

Paulius Morkūnas avatar James Cloos avatar Justas Medeišis avatar Ribhi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.