cheatah
Class

space::irbem::ContextResult

cheatah-space v0.1.0-alpha — Biome Standard 0.6.5-alpha

The outcome of a context build: a context, or the named reason there is none.

There is deliberately no default state and no public constructor. A struct of {optional<FieldContext>, ContextError} would have a value-initialized form carrying no context and no error — a success with nothing in it, which is exactly the sort of half-valid state this file exists to make unrepresentable. Both constructors here are private and each establishes the invariant that a context is present if and only if error is ContextError::None, so make_field_context is the only source of either half.

Functions

fn bool has_value() const noexcept #

Whether a context was built.

Returns

true exactly when error is ContextError::None.

Complexity

O(1).

Allocation

none.

fn ContextError error() const noexcept #

Why no context was built.

Returns

the failure, or ContextError::None when one was built.

Complexity

O(1).

Allocation

none.

fn const FieldContext & value() const #

The context that was built.

Returns

a reference to it; it lives as long as this result does.

Parameters
std::bad_optional_access

when the build failed — consult error first.

Complexity

O(1).

Allocation

none.

fn ContextResult · 2 overloads
ContextResult(const FieldContext &built)#
ContextResult(ContextError why)#

The success case.

Parameters
built

the validated context.

Complexity

O(1).

Allocation

none.

Constants & variables

var std::optional< FieldContext > context_ #

The context, engaged only on success.

var ContextError error_ #

Why there is none; ContextError::None on success.