|
tesseract++ 0.0.1
N-dimensional tensor library for embedded systems
|
A discriminated union holding either a success value or an error. More...
#include <expected.h>
Public Types | |
| using | value_type = T |
| using | error_type = E |
Public Member Functions | |
| Expected (T &&v) noexcept(is_nothrow_move_constructible_v< T >) | |
| Construct in the success state by moving a value in. | |
| Expected (Unexpected< E > u) noexcept | |
| Construct in the error state from an Unexpected tag. | |
| Expected (Expected &&other) noexcept(is_nothrow_move_constructible_v< T >) | |
| Move constructor. | |
| Expected & | operator= (Expected &&other) noexcept(is_nothrow_move_constructible_v< T >) |
| Move assignment. | |
| Expected (const Expected &)=delete | |
| Deleted — Expected is move-only to prevent accidental copies. | |
| Expected & | operator= (const Expected &)=delete |
| Deleted — Expected is move-only to prevent accidental copies. | |
| ~Expected () noexcept | |
| Destructor. Destroys the active union member. | |
| operator bool () const noexcept | |
| Returns true if the Expected holds a success value. | |
| bool | has_value () const noexcept |
| Returns true if the Expected holds a success value. | |
| T & | value () noexcept |
| Access the success value by reference. | |
| const T & | value () const noexcept |
| Access the success value by const reference. | |
| T & | operator* () noexcept |
| Dereference operator — access the success value. | |
| const T & | operator* () const noexcept |
| Dereference operator (const) — access the success value. | |
| T * | operator-> () noexcept |
| Arrow operator — access members of the success value. | |
| const T * | operator-> () const noexcept |
| Arrow operator (const) — access members of the success value. | |
| E | error () const noexcept |
| Access the error code. | |
A discriminated union holding either a success value or an error.
Designed for failable operations in the fused library (decompositions, solvers, etc.). Uses a union internally so that only the active member is ever constructed — on the error path, T is never touched.
Move-only by design to prevent accidental copies of large results (e.g. matrix types) on embedded targets. With C++17 guaranteed copy elision and NRVO, returning by value from algorithms is zero-cost.
Marked [[nodiscard]] so the compiler warns if a caller discards the result without checking the error state.
| T | Success value type. |
| E | Error type (e.g. MatrixStatus, FilterStatus). No default — callers must always specify the error type explicitly. |
| using Expected< T, E >::error_type = E |
| using Expected< T, E >::value_type = T |
|
inlinenoexcept |
Construct in the success state by moving a value in.
| v | The success value (moved from). |
|
inlinenoexcept |
Construct in the error state from an Unexpected tag.
| u | An Unexpected wrapper carrying the error code. |
|
inlinenoexcept |
Move constructor.
Placement-new constructs the active member from the source. The source is left in a valid but unspecified state.

|
delete |
Deleted — Expected is move-only to prevent accidental copies.
Destructor. Destroys the active union member.
|
inlinenoexcept |
Access the error code.
|
inlinenoexcept |
Returns true if the Expected holds a success value.
|
inlineexplicitnoexcept |
Returns true if the Expected holds a success value.
|
inlinenoexcept |
Dereference operator (const) — access the success value.
|
inlinenoexcept |
Dereference operator — access the success value.
|
inlinenoexcept |
Arrow operator (const) — access members of the success value.
|
inlinenoexcept |
Arrow operator — access members of the success value.
|
delete |
Deleted — Expected is move-only to prevent accidental copies.
|
inlinenoexcept |
Move assignment.
Destroys the current active member, then placement-new constructs from the source.

|
inlinenoexcept |
Access the success value by const reference.
|
inlinenoexcept |
Access the success value by reference.
| E Expected< T, E >::err_ |
| T Expected< T, E >::val_ |