diff --git a/expected.hpp b/expected.hpp index 73f9f16..874f467 100644 --- a/expected.hpp +++ b/expected.hpp @@ -606,28 +606,28 @@ namespace util constexpr const T& value() const& { if (!has_value()) - throw std::logic_error(); + throw std::logic_error("precondition error: doesn't have value"); return **this; } constexpr T& value() & { if (!has_value()) - throw std::logic_error(); + throw std::logic_error("precondition error: doesn't have value"); return **this; } constexpr const T&& value() const&& { if (!has_value()) - throw std::logic_error(); + throw std::logic_error("precondition error: doesn't have value"); return *std::move(*this); } constexpr T&& value() && { if (!has_value()) - throw std::logic_error(); + throw std::logic_error("precondition error: doesn't have value"); return *std::move(*this); } @@ -658,7 +658,7 @@ namespace util template constexpr T value_or(U&& v) const& { - if (has_value) + if (has_value()) return **this; else return static_cast(std::forward(v)); @@ -667,7 +667,7 @@ namespace util template constexpr T value_or(U&& v) && { - if (has_value) + if (has_value()) return std::move(**this); else return static_cast(std::forward(v)); @@ -930,7 +930,7 @@ namespace util constexpr void value() const { if (!has_value()) - throw std::logic_error(); + throw std::logic_error("precondition error: doesn't have value"); } constexpr const E& error() const& diff --git a/monads.hpp b/monads.hpp index 928f401..fd62580 100644 --- a/monads.hpp +++ b/monads.hpp @@ -67,7 +67,7 @@ namespace monad } template - constexpr std::error_code get_error(T&& v, Ts&&... vs) noexcept + std::error_code get_error(T&& v, Ts&&... vs) noexcept { if constexpr (is_monad_v>) if (!has_value(v))