template <typename T, typename E>

class Result

Defined at line 15 of file ../../src/developer/debug/shared/result.h

Public Methods

void Result<T, E> (E e)

Defined at line 19 of file ../../src/developer/debug/shared/result.h

void Result<T, E> (T v)

Defined at line 21 of file ../../src/developer/debug/shared/result.h

bool ok ()

Defined at line 23 of file ../../src/developer/debug/shared/result.h

bool has_error ()

Defined at line 24 of file ../../src/developer/debug/shared/result.h

const E & err ()

Requires that has_error be true or this function will crash. See also err_or_empty().

Defined at line 27 of file ../../src/developer/debug/shared/result.h

const T & value ()

Requires that has_error be false or this function will crash. See also [take_]value_or_empty().

Defined at line 33 of file ../../src/developer/debug/shared/result.h

T & value ()

Defined at line 37 of file ../../src/developer/debug/shared/result.h

T take_value ()

Defined at line 41 of file ../../src/developer/debug/shared/result.h

bool operator bool ()

Implicit conversion to bool indicating "OK".

Defined at line 47 of file ../../src/developer/debug/shared/result.h

E err_or_empty ()

These functions are designed for integrating with code that uses an (E, T) pair. If this

class isn't in the corresponding state, default constructs the missing object.

The value version can optionally destructively move the value out (with the "take" variant)

since some values are inefficient to copy and often this is used in a context where the value

is no longer needed.

The E version does not allow destructive moving because it would leave this object in an

inconsistent state where the error object is stored in the variant, but err().has_error() is

not set. We assume that errors are unusual so are not worth optimizing for saving one string

copy to avoid this.

Defined at line 60 of file ../../src/developer/debug/shared/result.h

T value_or_empty ()

Defined at line 65 of file ../../src/developer/debug/shared/result.h

T take_value_or_empty ()

Defined at line 70 of file ../../src/developer/debug/shared/result.h

bool operator== (const Result<T, E> & other)

Comparators for unit tests.

Defined at line 77 of file ../../src/developer/debug/shared/result.h

bool operator!= (const Result<T, E> & other)

Defined at line 84 of file ../../src/developer/debug/shared/result.h