mrdocs::polyfill::expected

A container holding an error or a value.

Synopsis

template<
    class T,
    class E>
class expected;

Description

Monadic result type holding either a value T or an unexpected error E.

Type Aliases

Name

Description

error_type

Type produced on failure.

rebind

Rebind to an expected with a different value type and the same error type.

unexpected_type

Convenience alias for an unexpected containing the error type.

value_type

Type produced on success.

Member Functions

Name

Description

expected [constructor]

Constructors

~expected [destructor]

Destructors

operator=

Assignment operators

and_then

and_then overloads

emplace

emplace overloads

error

Access the stored error; precondition: !has_value().

error_or

error_or overloads

has_value

Return true when the expected contains a value.

operator*

Dereference operators

operator‐>

Access value members through pointer syntax.

or_else

or_else overloads

swap

Swap the stored state with another expected.

transform

transform overloads

transform_error

transform_error overloads

value

value overloads

value_or

value_or overloads

operator bool

Return true when the expected contains a value.

Data Members

Name

Description

unex_ [variant member]

Storage for the unexpected error.

val_ [variant member]

Storage for the engaged value.

Specializations

Name

Description

expected<T, E>

expected specialization for void values. Holds either success (no payload) or an unexpected error E.

expected<T&, E>

expected specialization for lvalue references. Holds either a bound reference to T or an unexpected error E.

Friends

Name

Description

mrdocs::polyfill::swap

Swap contents with another expected.

mrdocs::polyfill::operator==

Equality operator

mrdocs::polyfill::operator==

Equality operator

mrdocs::polyfill::operator==

Equality operator

mrdocs::polyfill::expected

A container holding an error or a value.

Created with MrDocs