17 template <
class Value,
class Error = Placeholder>
42 std::forward<T>(value)
48 return Ok(std::forward<T>(value));
51 template <
class... Args>
54 std::forward<Args>(args)...
68 return Err(std::forward<E>(
error));
71 template <
class... Args>
74 std::forward<Args>(args)...
107 operator bool()
const{
112 return this->value();
120 return &(this->
get());
126 return this->value();
131 return this->toOptional();
134 template <
class T = value_type>
141 template <
class T = value_type>
143 return this->
map(mapper);
146 template <
class E = error_type>
153 template <
class T = value_type,
class E = error_type>
161 template <
class T = value_type,
class E = error_type>
164 ? mapper(this->value())
168 template <
class T = value_type,
class E = error_type>
170 return this->flatMap(mapper);
173 template <
class T = value_type,
class E = error_type>
177 : mapper(this->
error());
209 return this->value();
220 std::current_exception()
Result< T, error_type > map(std::function< T(const value_type &)> mapper) const
static Result err(E &&error)
static InvalidResultAccess okWhenErr()
Helper function that creates an InvalidResultAccess when trying to access Ok when Err...
Global namespace of the SCL.
static Result emplaceErr(Args &&... args)
const value_type & okOr(const value_type &value) const
const error_type & errOr(std::function< const error_type &()> factory) const
Optional< value_type > toOptional() const
bool hasLeft() const
Determines whether or not LHS is the active alternative.
Result< T, E > mapBoth(std::function< T(const value_type &)> valueMapper, std::function< E(const error_type &)> errorMapper) const
const value_type & okOrThrow(E ex) const
Result< T, E > flatMapError(std::function< Result< T, E >(const error_type &)> mapper) const
Result< value_type, E > mapError(std::function< E(const error_type &)> mapper) const
const value_type & operator*() const
static InvalidResultAccess errWhenOk()
Helper function that creates an InvalidResultAccess when trying to access Err when Ok is active...
Result(details::result_value, T &&value)
const error_type & errOr(const error_type &error) const
const error_type & error() const
Optional< value_type > asOptional() const
Result< T, E > andThen(std::function< Result< T, E >(const value_type &)> mapper) const
constexpr None none
A constant global variable of type None.
const value_type *const operator->() const
const Rhs & getRight() const
Attempts to get the RHS value.
static Result Err(E &&err)
const value_type & okOr(std::function< const value_type &()> factory) const
static Result emplaceOk(Args &&... args)
Result< T, std::exception_ptr > wrapInResult(std::function< T()> f)
const value_type & value() const
static Result ok(T &&value)
details::map_toolbox< T, U > map(F &&mapper)
Map a stream.
Exception class used when attempting to access the wrong type stored in an scl::utils::Either.
Result(details::result_error, E &&err)
Result< T, E > flatMap(std::function< Result< T, E >(const value_type &)> mapper) const
const Lhs & getLeft() const
Attempts to get the LHS value.
Result< T, error_type > then(std::function< T(const value_type &)> mapper) const
static Result Ok(T &&value)