Skip to content

Repository files navigation

zeus::expected

Tests Workflow GitHub Release Conan Center

A C++17 backport of std::expected, designed for API compatibility with the standard library.

Features

Implemented C++ Standard Proposals:

  • P0323R12 <expected>
  • P2505R5 Monadic Functions For expected
  • P2549R1 std::unexpected<E> should have error() as member accessor
  • P3379R0 Constrain std::expected equality operators

Implemented LWG Issues:

  • LWG-3836 std::expected<bool, E1> conversion constructor expected(const expected<U, G>&) should take precedence over expected(U&&) with operator bool
  • LWG-3843 std::expected<T,E>::value() & assumes E is copy constructible
  • LWG-3940 std::expected<void, E>::value() also needs E to be copy constructible
  • LWG-4026 Assignment operators of std::expected should propagate triviality
  • LWG-3877 incorrect constraints on const-qualified monadic overloads for std::expected
  • LWG-3886 Monad mo' problems
  • LWG-4031 bad_expected_access<void> member functions should be noexcept
  • LWG-4222 expected constructor from a single value missing a constraint
  • LWG-4025 Move assignment operator of std::expected<cv void, E> should not be conditionally deleted
  • LWG-4366 Heterogeneous comparison of expected may be ill-formed

Enhancements:

  • Enhanced noexcept (covered by tests from MSVC's STL)

Compiler support

A conforming C++17 implementation is required. Higher language standards are also supported and can provide benefits such as enhanced constexpr capabilities.

Compiler Supported versions
MSVC v142 and later
GCC 8 and later
Clang 11 and later

See the CI workflow for the compiler and language standard combinations that are continuously tested. Other conforming compilers may also work. Feedback is welcome.

Building and testing

Catch2 is required to build the tests. You may choose any preferred package manager to introduce the requirements. Here is a conan way.

# install the requirements
conan install . -s build_type=Debug -b missing
# configure, build and test with cmake
# ...

Acknowledgements

  • tl-expected, the original code base this library came from.
  • MSVC's STL's massive, strong and robust tests.

About

Backporting std::expected to C++17.

Topics

Resources

Stars

43 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages