class result

Defined at line 226 of file ../../sdk/lib/fit/include/lib/fit/result.h

Specialization of result for one value type.

Functions

result<E, T>

public void result<E, T>(const result<E, T> & )

Defined at line 243 of file ../../sdk/lib/fit/include/lib/fit/result.h

operator=

public result<E, T> & operator=(const result<E, T> & )

Defined at line 244 of file ../../sdk/lib/fit/include/lib/fit/result.h

result<E, T>

public void result<E, T>(result<E, T> && )

Defined at line 245 of file ../../sdk/lib/fit/include/lib/fit/result.h

operator=

public result<E, T> & operator=(result<E, T> && )

Defined at line 246 of file ../../sdk/lib/fit/include/lib/fit/result.h

result<E, T>

public void result<E, T>(failed_or_none )

Defined at line 250 of file ../../sdk/lib/fit/include/lib/fit/result.h

Implicit conversion from fit::failed. This overload is only enabled when the error type E is fit::failed.

result<E, T>

public void result<E, T>(success<U> success)

Defined at line 254 of file ../../sdk/lib/fit/include/lib/fit/result.h

Implicit conversion from success<U>, where T is constructible from U.

result<E, T>

public void result<E, T>(error<F> error)

Defined at line 259 of file ../../sdk/lib/fit/include/lib/fit/result.h

Implicit conversion from error<F>, where E is constructible from F.

result<E, T>

public void result<E, T>(result<F, U> other)

Defined at line 266 of file ../../sdk/lib/fit/include/lib/fit/result.h

Implicitly constructs a result from another result with compatible types.

is_ok

public bool is_ok()

Defined at line 271 of file ../../sdk/lib/fit/include/lib/fit/result.h

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.

is_error

public bool is_error()

Defined at line 272 of file ../../sdk/lib/fit/include/lib/fit/result.h

error_value

public E & error_value()

Defined at line 277 of file ../../sdk/lib/fit/include/lib/fit/result.h

Accessors for the underlying error.

May only be called when the result contains an error.

error_value

public const E & error_value()

Defined at line 283 of file ../../sdk/lib/fit/include/lib/fit/result.h

error_value

public E && error_value()

Defined at line 289 of file ../../sdk/lib/fit/include/lib/fit/result.h

error_value

public const E && error_value()

Defined at line 295 of file ../../sdk/lib/fit/include/lib/fit/result.h

take_error

public error<E> take_error()

Defined at line 306 of file ../../sdk/lib/fit/include/lib/fit/result.h

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.

value

public T & value()

Defined at line 316 of file ../../sdk/lib/fit/include/lib/fit/result.h

Accessors for the underlying value.

May only be called when the result contains a value.

value

public const T & value()

Defined at line 322 of file ../../sdk/lib/fit/include/lib/fit/result.h

value

public T && value()

Defined at line 328 of file ../../sdk/lib/fit/include/lib/fit/result.h

value

public const T && value()

Defined at line 334 of file ../../sdk/lib/fit/include/lib/fit/result.h

take_value

public success<T> take_value()

Defined at line 345 of file ../../sdk/lib/fit/include/lib/fit/result.h

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.

value_or

public T value_or(U && default_value)

Defined at line 356 of file ../../sdk/lib/fit/include/lib/fit/result.h

Contingent accessors for the underlying value.

Returns the value when the result has a value, otherwise returns the given default value.

value_or

public T value_or(U && default_value)

Defined at line 363 of file ../../sdk/lib/fit/include/lib/fit/result.h

operator->

public decltype(auto) operator->()

Defined at line 374 of file ../../sdk/lib/fit/include/lib/fit/result.h

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.

operator->

public decltype(auto) operator->()

Defined at line 380 of file ../../sdk/lib/fit/include/lib/fit/result.h

operator*

public T & operator*()

Defined at line 390 of file ../../sdk/lib/fit/include/lib/fit/result.h

Accessors for the underlying value. This is a syntax sugar for value().

May only be called when the result contains a value.

operator*

public const T & operator*()

Defined at line 391 of file ../../sdk/lib/fit/include/lib/fit/result.h

operator*

public T && operator*()

Defined at line 392 of file ../../sdk/lib/fit/include/lib/fit/result.h

operator*

public const T && operator*()

Defined at line 393 of file ../../sdk/lib/fit/include/lib/fit/result.h

operator+=

public result<E, T> & operator+=(error<F> error)

Defined at line 402 of file ../../sdk/lib/fit/include/lib/fit/result.h

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.

map_error

public result<std::invoke_result_t<Fn, E>, T> map_error(Fn && fn)

Defined at line 420 of file ../../sdk/lib/fit/include/lib/fit/result.h

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.

map_error

public result<std::invoke_result_t<Fn, E>, T> map_error(Fn && fn)

Defined at line 427 of file ../../sdk/lib/fit/include/lib/fit/result.h

map_error

public result<std::invoke_result_t<Fn, E>, T> map_error(Fn && fn)

Defined at line 434 of file ../../sdk/lib/fit/include/lib/fit/result.h

map_error

public result<std::invoke_result_t<Fn, E>, T> map_error(Fn && fn)

Defined at line 441 of file ../../sdk/lib/fit/include/lib/fit/result.h

swap

public void swap(result<E, T> & other)

Defined at line 448 of file ../../sdk/lib/fit/include/lib/fit/result.h

result<E, T>

protected void result<E, T>()

Defined at line 457 of file ../../sdk/lib/fit/include/lib/fit/result.h

Default constructs a result in empty state.

reset

protected void reset()

Defined at line 461 of file ../../sdk/lib/fit/include/lib/fit/result.h

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.

class result

class result

Defined at line 471 of file ../../sdk/lib/fit/include/lib/fit/result.h

Specialization of the result type for zero values.

Records

Functions

result<E>

public void result<E>(const result<E> & )

Defined at line 486 of file ../../sdk/lib/fit/include/lib/fit/result.h

operator=

public result<E> & operator=(const result<E> & )

Defined at line 487 of file ../../sdk/lib/fit/include/lib/fit/result.h

result<E>

public void result<E>(result<E> && )

Defined at line 488 of file ../../sdk/lib/fit/include/lib/fit/result.h

operator=

public result<E> & operator=(result<E> && )

Defined at line 489 of file ../../sdk/lib/fit/include/lib/fit/result.h

result<E>

public void result<E>(failure_or_none )

Defined at line 493 of file ../../sdk/lib/fit/include/lib/fit/result.h

Implicit conversion from fit::failure. This overload is only enabled when the error type E is fit::failed.

result<E>

public void result<E>( success )

Defined at line 496 of file ../../sdk/lib/fit/include/lib/fit/result.h

Implicit conversion from fit::success<>.

result<E>

public void result<E>(error<F> error)

Defined at line 500 of file ../../sdk/lib/fit/include/lib/fit/result.h

Implicit conversion from error<F>, where E is constructible from F.

result<E>

public void result<E>(result<F> other)

Defined at line 505 of file ../../sdk/lib/fit/include/lib/fit/result.h

Implicitly constructs a result from another result with compatible types.

is_ok

public bool is_ok()

Defined at line 508 of file ../../sdk/lib/fit/include/lib/fit/result.h

Predicates indicating whether the result contains a value or an error.

is_error

public bool is_error()

Defined at line 509 of file ../../sdk/lib/fit/include/lib/fit/result.h

error_value

public E & error_value()

Defined at line 514 of file ../../sdk/lib/fit/include/lib/fit/result.h

Accessors for the underlying error.

May only be called when the result contains an error.

error_value

public const E & error_value()

Defined at line 520 of file ../../sdk/lib/fit/include/lib/fit/result.h

error_value

public E && error_value()

Defined at line 526 of file ../../sdk/lib/fit/include/lib/fit/result.h

error_value

public const E && error_value()

Defined at line 532 of file ../../sdk/lib/fit/include/lib/fit/result.h

take_error

public error<E> take_error()

Defined at line 543 of file ../../sdk/lib/fit/include/lib/fit/result.h

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.

operator+=

public result<E> & operator+=(error<F> error)

Defined at line 556 of file ../../sdk/lib/fit/include/lib/fit/result.h

Augments the error value of the result with the given 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.

map_error

public result<std::invoke_result_t<Fn, E>> map_error(Fn && fn)

Defined at line 574 of file ../../sdk/lib/fit/include/lib/fit/result.h

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 in the current result object will be moved.

map_error

public result<std::invoke_result_t<Fn, E>> map_error(Fn && fn)

Defined at line 581 of file ../../sdk/lib/fit/include/lib/fit/result.h

map_error

public result<std::invoke_result_t<Fn, E>> map_error(Fn && fn)

Defined at line 588 of file ../../sdk/lib/fit/include/lib/fit/result.h

map_error

public result<std::invoke_result_t<Fn, E>> map_error(Fn && fn)

Defined at line 595 of file ../../sdk/lib/fit/include/lib/fit/result.h

swap

public void swap(result<E> & other)

Defined at line 602 of file ../../sdk/lib/fit/include/lib/fit/result.h

result<E>

protected void result<E>()

Defined at line 611 of file ../../sdk/lib/fit/include/lib/fit/result.h

Default constructs a result in empty state.

reset

protected void reset()

Defined at line 615 of file ../../sdk/lib/fit/include/lib/fit/result.h

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.

class result

class result

Result type representing either an error or zero/one return values.

Base type.