30 [[nodiscard]]
bool has_value() const noexcept {
return value_.
has_value(); }
31 explicit operator bool() const noexcept {
return value_.has_value(); }
43 return std::move(*value_);
48 return value_ ? *value_ :
static_cast<T
>(std::forward<U>(fallback));
52 const T*
operator->() const noexcept {
return &*value_; }
54 const T&
operator*() const& noexcept {
return *value_; }
57 std::error_code
code() const noexcept {
return value_ ? std::error_code{} : error_.code; }
65 using R = std::invoke_result_t<F, T&&>;
66 if (value_)
return std::forward<F>(f)(std::move(*value_));
72 using U = std::invoke_result_t<F, T&&>;
73 if (value_)
return Result<U>(std::forward<F>(f)(std::move(*value_)));
79 if (value_)
return std::move(*
this);
80 return std::forward<F>(f)(error_);
84 std::optional<T> value_;
97 [[nodiscard]]
bool has_value() const noexcept {
return has_value_; }
98 explicit operator bool() const noexcept {
return has_value_; }
105 std::error_code
code() const noexcept {
return has_value_ ? std::error_code{} : error_.code; }
113 using R = std::invoke_result_t<F>;
114 if (has_value_)
return std::forward<F>(f)();
bool has_value() const noexcept
Definition result.hpp:97
void value() const
Definition result.hpp:100
void throw_if_error() const
Definition result.hpp:107
auto and_then(F &&f) &&
Definition result.hpp:112
void value_type
Definition result.hpp:91
const ErrorInfo & error() const &noexcept
Definition result.hpp:104
Result(ErrorInfo error)
Definition result.hpp:95
Result()
Definition result.hpp:94
std::error_code code() const noexcept
Definition result.hpp:105
T value_type
Definition result.hpp:18
std::error_code code() const noexcept
Definition result.hpp:57
void throw_if_error() const
Definition result.hpp:59
Result(Result &&) noexcept=default
Result(T value)
Definition result.hpp:21
const T & value() const &
Definition result.hpp:37
T && value() &&
Definition result.hpp:41
Result(ErrorInfo error)
Definition result.hpp:22
T value_or(U &&fallback) const &
Definition result.hpp:47
auto transform(F &&f) &&
Definition result.hpp:71
const ErrorInfo & error() const &noexcept
Definition result.hpp:56
bool has_value() const noexcept
Definition result.hpp:30
Result(const Result &)=default
T * operator->() noexcept
Definition result.hpp:51
T & value() &
Definition result.hpp:33
auto and_then(F &&f) &&
Definition result.hpp:64
T & operator*() &noexcept
Definition result.hpp:53
const T & operator*() const &noexcept
Definition result.hpp:54
Result or_else(F &&f) &&
Definition result.hpp:78
const T * operator->() const noexcept
Definition result.hpp:52
SSHPP_INLINE void throw_error(ErrorInfo info)
Definition error.ipp:152