Template Class output_t

Class Documentation

template<typename type>
class output_t

Generic output wrapper holding a value and an error state.

Template Parameters:

type – Stored value type.

Public Functions

inline output_t()

Default constructor.

inline output_t(const type &value_)

Constructs from value by copy.

Parameters:

value_ – Value copied into the output container.

inline output_t(type &&value_)

Constructs from value by move.

Parameters:

value_ – Value moved into the output container.

inline output_t(const type &value_, const fail_t &error_)

Constructs from value and error by copy.

Parameters:
  • value_ – Value copied into the output container.

  • error_ – Failure state copied into the output container.

inline output_t(type &&value_, const fail_t &error_)

Constructs from moved value and copied error.

Parameters:
  • value_ – Value moved into the output container.

  • error_ – Failure state copied into the output container.

inline output_t(const type &value_, fail_t &&error_)

Constructs from copied value and moved error.

Parameters:
  • value_ – Value copied into the output container.

  • error_ – Failure state moved into the output container.

inline output_t(type &&value_, fail_t &&error_)

Constructs from moved value and moved error.

Parameters:
  • value_ – Value moved into the output container.

  • error_ – Failure state moved into the output container.

inline output_t(const fail_t &error_)

Constructs from error only.

Parameters:

error_ – Failure state copied into the output container.

inline output_t(fail_t &&error_)

Constructs from moved error only.

Parameters:

error_ – Failure state moved into the output container.

inline type &get()

Returns the stored value.

Returns:

Mutable reference to the stored value.

inline const type &get() const

Returns the stored value (const).

Returns:

Const reference to the stored value.

inline fail_t &get_error()

Returns the stored error.

Returns:

Mutable reference to the stored failure state.

inline const fail_t &get_error() const

Returns the stored error (const).

Returns:

Const reference to the stored failure state.

inline bool fail() const

Returns whether this output represents a failure.

Returns:

true when the stored fail_t indicates an error.

inline operator type&() &

Implicit conversion to the contained value (mutable lvalue).

inline operator const type&() const &

Implicit conversion to the contained value (const lvalue).

inline operator type&&() &&

Implicit conversion to the contained value (rvalue).

inline operator fail_t() const

Implicit conversion to the contained fail_t.

Returns:

Copy of the stored failure state.

inline bool operator==(const fail_t &fail_) const

Compares the stored error to a failure code.

Parameters:

fail_ – Failure code compared against the stored error.

Returns:

true when the stored failure equals fail_.

inline bool operator!=(const fail_t &fail_) const

Compares the stored error to a failure code.

Parameters:

fail_ – Failure code compared against the stored error.

Returns:

true when the stored failure differs from fail_.

inline auto operator->()

Pointer-like access to the stored value.

inline auto operator->() const

Pointer-like access to the stored value (const).

inline decltype(auto) operator*() const

Dereferences the stored pointer-like value (const).

inline decltype(auto) operator*()

Dereferences the stored pointer-like value.

Private Functions

inline void __check_ok() const

Asserts that this output is not a failure.

Private Members

fail_t _error

Stored failure state.

type _value

Stored value.