Template Class output_t
Defined in File output.hpp
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 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:
truewhen the storedfail_tindicates an error.
-
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:
truewhen the stored failure equalsfail_.
-
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:
truewhen the stored failure differs fromfail_.
-
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.