Expected
Backporting std::expected to C++17.
Install / Use
/learn @zeus-cpp/ExpectedREADME
zeus::expected
Backporting std::expected to C++17.
Features
Implemented C++ Standard Proposals:
- [x] P0323R12
<expected> - [x] P2505R5 Monadic Functions For expected
- [x] P2549R1
std::unexpected<E>should haveerror()as member accessor
Implemented LWG Issues:
- [x] LWG-3836
std::expected<bool, E1>conversion constructorexpected(const expected<U, G>&)should take precedence overexpected(U&&)withoperator bool - [x] LWG-3843
std::expected<T,E>::value() &assumesEis copy constructible - [x] LWG-3940
std::expected<void, E>::value()also needsEto be copy constructible - [x] LWG-4026 Assignment operators of
std::expectedshould propagate triviality - [x] LWG-3877 incorrect constraints on const-qualified monadic overloads for
std::expected - [x] LWG-3886 Monad mo' problems
Enhancements:
- Enhanced noexcept (covered by tests from MSVC's STL)
Compiler supports
Any compiler that supports C++17 should work.
Higher language standards are also supported, which can provide benefits such as enhanced constexpr capabilities.
List of known compiler supported:
- MSVC v142 and later
- GCC 8 and later
Feedbacks are 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.
