13 #ifndef __STOUT_RESULT_HPP__ 14 #define __STOUT_RESULT_HPP__ 67 typename =
typename std::enable_if<
68 std::is_constructible<T, const U&>::value>
::type>
116 T&
get() & {
return get(*this); }
117 const T&
get()
const& {
return get(*this); }
118 T&&
get() && {
return get(std::move(*
this)); }
119 const T&&
get()
const&& {
return get(std::move(*
this)); }
126 const T&&
operator*() const&& {
return std::move(*this).get(); }
133 template <
typename Self>
134 static auto get(Self&&
self)
135 -> decltype(**(std::forward<Self>(
self).data))
138 std::string errorMessage =
"Result::get() but state == ";
140 errorMessage +=
"ERROR: " +
self.data.error();
141 }
else if (
self.
isNone()) {
142 errorMessage +=
"NONE";
146 return **(std::forward<Self>(
self).data);
155 #endif // __STOUT_RESULT_HPP__ bool isNone() const
Definition: result.hpp:113
Definition: errorbase.hpp:36
Result(const _Some< U > &some)
Definition: result.hpp:86
Definition: option.hpp:29
#define ABORT(...)
Definition: abort.hpp:40
Result(const Try< T > &_t)
Definition: result.hpp:77
Result(const U &u)
Definition: result.hpp:69
static Result< T > error(const std::string &message)
Definition: result.hpp:54
Definition: error.hpp:108
Result< T > & operator=(const Result< T > &that)=default
Definition: type_utils.hpp:619
Definition: errorbase.hpp:50
const T * operator->() const
Definition: result.hpp:121
Result(const None &none)
Definition: result.hpp:82
const T & operator*() const &
Definition: result.hpp:124
Result(const T &_t)
Definition: result.hpp:59
Result(const Error &error)
Definition: result.hpp:89
Result(T &&_t)
Definition: result.hpp:62
static Result< T > some(const T &t)
Definition: result.hpp:49
bool isSome() const
Definition: try.hpp:77
static Try error(const E &e)
Definition: try.hpp:43
T * operator->()
Definition: result.hpp:122
_Some< typename std::decay< T >::type > Some(T &&t)
Definition: some.hpp:42
T && operator*()&&
Definition: result.hpp:127
bool isError() const
Definition: try.hpp:78
const T && operator*() const &&
Definition: result.hpp:126
T & get()&
Definition: result.hpp:116
Try< uint32_t > type(const std::string &path)
bool isSome() const
Definition: result.hpp:112
bool isError() const
Definition: result.hpp:114
Result(const ErrnoError &error)
Definition: result.hpp:92
const std::string & error() const
Definition: result.hpp:129
static Result< T > none()
Definition: result.hpp:44
Result(const Option< T > &option)
Definition: result.hpp:72
T & operator*()&
Definition: result.hpp:125