template <typename E, typename T>
class result
Defined at line 226 of file ../../sdk/lib/fit/include/lib/fit/result.h
Specialization of result for one value type.
Public Methods
void result<E, T> (const result<E, T> & )
Defined at line 243 of file ../../sdk/lib/fit/include/lib/fit/result.h
result<E, T> & operator= (const result<E, T> & )
Defined at line 244 of file ../../sdk/lib/fit/include/lib/fit/result.h
void result<E, T> (result<E, T> && )
Defined at line 245 of file ../../sdk/lib/fit/include/lib/fit/result.h
result<E, T> & operator= (result<E, T> && )
Defined at line 246 of file ../../sdk/lib/fit/include/lib/fit/result.h
template <class... Args>
void result<E, T> (std::in_place_t , success<> , Args &&... args)
Defined at line 249 of file ../../sdk/lib/fit/include/lib/fit/result.h
template <class... Args>
void result<E, T> (std::in_place_t , success<> , Args &&... args)
Defined at line 249 of file ../../sdk/lib/fit/include/lib/fit/result.h
void result<E, T> (failed_or_none )
Implicit conversion from fit::failed. This overload is only enabled when the error type E is
fit::failed.
Defined at line 254 of file ../../sdk/lib/fit/include/lib/fit/result.h
template <typename U, ::fit::internal::requires_conditions<std::is_constructible<T, U>> = true>
void result<E, T> (success<U> success)
Implicit conversion from success
<U
>, where T is constructible from U.
Defined at line 258 of file ../../sdk/lib/fit/include/lib/fit/result.h
template <typename F, ::fit::internal::requires_conditions<std::is_constructible<E, F>> = true>
void result<E, T> (error<F> error)
Implicit conversion from error
<F
>, where E is constructible from F.
Defined at line 263 of file ../../sdk/lib/fit/include/lib/fit/result.h
template <typename F, typename U, ::fit::internal::requires_conditions<not_same<result<F, U>>, std::is_constructible<E, F>,
std::is_constructible<T, U>> = true>
void result<E, T> (result<F, U> other)
Implicitly constructs a result from another result with compatible types.
Defined at line 270 of file ../../sdk/lib/fit/include/lib/fit/result.h
bool is_ok ()
Predicates indicating whether the result contains a value or an error. The positive values are
mutually exclusive, however, both predicates are negative when the result is default
constructed to the empty state.
Defined at line 275 of file ../../sdk/lib/fit/include/lib/fit/result.h
bool is_error ()
Defined at line 276 of file ../../sdk/lib/fit/include/lib/fit/result.h
E & error_value ()
Accessors for the underlying error.
May only be called when the result contains an error.
Defined at line 281 of file ../../sdk/lib/fit/include/lib/fit/result.h
const E & error_value ()
Defined at line 287 of file ../../sdk/lib/fit/include/lib/fit/result.h
E && error_value ()
Defined at line 293 of file ../../sdk/lib/fit/include/lib/fit/result.h
const E && error_value ()
Defined at line 299 of file ../../sdk/lib/fit/include/lib/fit/result.h
error<E> take_error ()
Moves the underlying error and returns it as an instance of fit::error, simplifying
propagating the error to another fit::result.
May only be called when the result contains an error.
Defined at line 310 of file ../../sdk/lib/fit/include/lib/fit/result.h
T & value ()
Accessors for the underlying value.
May only be called when the result contains a value.
Defined at line 320 of file ../../sdk/lib/fit/include/lib/fit/result.h
const T & value ()
Defined at line 326 of file ../../sdk/lib/fit/include/lib/fit/result.h
T && value ()
Defined at line 332 of file ../../sdk/lib/fit/include/lib/fit/result.h
const T && value ()
Defined at line 338 of file ../../sdk/lib/fit/include/lib/fit/result.h
success<T> take_value ()
Moves the underlying value and returns it as an instance of fit::success, simplifying
propagating the value to another fit::result.
May only be called when the result contains a value.
Defined at line 349 of file ../../sdk/lib/fit/include/lib/fit/result.h
template <typename U, ::fit::internal::requires_conditions<std::is_constructible<T, U>> = true>
T value_or (U && default_value)
Contingent accessors for the underlying value.
Returns the value when the result has a value, otherwise returns the given default value.
Defined at line 360 of file ../../sdk/lib/fit/include/lib/fit/result.h
template <typename U, ::fit::internal::requires_conditions<std::is_constructible<T, U>> = true>
T value_or (U && default_value)
Defined at line 367 of file ../../sdk/lib/fit/include/lib/fit/result.h
decltype(auto) operator-> ()
Accessors for the members of the underlying value. These operators forward to T::operator->()
when defined, otherwise they provide direct access to T*.
May only be called when the result contains a value.
Defined at line 378 of file ../../sdk/lib/fit/include/lib/fit/result.h
decltype(auto) operator-> ()
Defined at line 384 of file ../../sdk/lib/fit/include/lib/fit/result.h
T & operator* ()
Accessors for the underlying value. This is a syntax sugar for value().
May only be called when the result contains a value.
Defined at line 394 of file ../../sdk/lib/fit/include/lib/fit/result.h
const T & operator* ()
Defined at line 395 of file ../../sdk/lib/fit/include/lib/fit/result.h
T && operator* ()
Defined at line 396 of file ../../sdk/lib/fit/include/lib/fit/result.h
const T && operator* ()
Defined at line 397 of file ../../sdk/lib/fit/include/lib/fit/result.h
template <typename F, ::fit::internal::requires_conditions<
std::is_class<E>, ::fit::internal::has_plus_equals<E, F>> = true>
result<E, T> & operator+= (error<F> error)
Augments the error value of the result with the given error value. The operator
E::operator+=(F) must be defined. Additionally, E may not be a pointer, primitive, or enum
type.
May only be called when the result contains an error.
Defined at line 406 of file ../../sdk/lib/fit/include/lib/fit/result.h
template <typename Fn>
result<std::invoke_result_t<Fn, E>, T> map_error (Fn && fn)
Maps a result
<E
, T> to a result
<E2
, T> by transforming the error through
fn, where E2 is the result of invoking fn on E. Success values will be
passed through untouched.
Note that map_error is not necessary if E2 is constructible from E.
In that case, result
<E2
, T> will be constructible from result
<E
, T>.
If the current object is an r-value, errors and successes in the current
result object will be moved.
Defined at line 424 of file ../../sdk/lib/fit/include/lib/fit/result.h
template <typename Fn>
result<std::invoke_result_t<Fn, E>, T> map_error (Fn && fn)
Defined at line 431 of file ../../sdk/lib/fit/include/lib/fit/result.h
template <typename Fn>
result<std::invoke_result_t<Fn, E>, T> map_error (Fn && fn)
Defined at line 438 of file ../../sdk/lib/fit/include/lib/fit/result.h
template <typename Fn>
result<std::invoke_result_t<Fn, E>, T> map_error (Fn && fn)
Defined at line 445 of file ../../sdk/lib/fit/include/lib/fit/result.h
void swap (result<E, T> & other)
Defined at line 452 of file ../../sdk/lib/fit/include/lib/fit/result.h
Protected Methods
void result<E, T> ()
Default constructs a result in empty state.
Defined at line 461 of file ../../sdk/lib/fit/include/lib/fit/result.h
void reset ()
Reset is not a recommended operation for the general result pattern. This method is provided
for derived types that need it for specific use cases.
Defined at line 465 of file ../../sdk/lib/fit/include/lib/fit/result.h
Friends
template <typenametypename>
class result