|
| constexpr | Expected (std::source_location loc=std::source_location::current()) |
| | Constructs a default fatal-error Expected, logs error.
|
| constexpr | Expected (ErrorCode error, const char *message="", std::source_location loc=std::source_location::current()) |
| | Constructs an error Expected with given code and message, logs error.
|
| template<typename U = T, typename = std::enable_if_t<!std::is_reference_v<U>>> |
| constexpr | Expected (U value, std::source_location loc=std::source_location::current()) |
| | Constructs a successful Expected holding a value (value types only).
|
| template<typename U = T, typename = std::enable_if_t<std::is_reference_v<U>>> |
| constexpr | Expected (std::remove_reference_t< T > &value, std::source_location loc=std::source_location::current()) |
| | Constructs a successful Expected holding a reference (reference types only).
|
| constexpr | Expected (Expected &&other) noexcept |
| | Move constructor, leaves source in OBJECT_MOVED state.
|
| constexpr Expected & | operator= (Expected &&other) noexcept |
| | Move assignment, leaves source in OBJECT_MOVED state.
|
| | Expected (const Expected &)=delete |
| Expected & | operator= (const Expected &)=delete |
| constexpr bool | IsSuccess () const noexcept |
| | Returns true if the Expected holds a success code.
|
| constexpr bool | IsFailure () const noexcept |
| | Returns true if the Expected holds an error.
|
| void | Terminate () const |
| | Closes the application immediately.
|
| constexpr auto | Value () -> std::conditional_t< std::is_reference_v< T >, std::remove_reference_t< T > &, T & > |
| | Accesses the stored value (lvalue reference for references, value for value types).
|
| constexpr auto | Value () const -> std::conditional_t< std::is_reference_v< T >, const std::remove_reference_t< T > &, const T & > |
| | Const overload of Value().
|
| constexpr ErrorCode | Error () const |
| | Gets the stored error code.
|
| constexpr std::string_view | ErrorToString () const |
| | Gets the error code as a string.
|
| constexpr const char * | Message () const |
| | Gets the error message.
|
| constexpr const char * | Function () const |
| | Gets the function name where this Expected was created.
|
template<typename T>
class Raven::Expected< T >
Template representing either a valid value or an error.
- Template Parameters
-
| T | The type of the expected value, or a reference type. |
The Expected<T> class encapsulates either a successfully produced value of type T or an error condition. It supports move-only semantics, automatic logging of errors on construction, and integration with the Application lifecycle (Terminate on failure). Error codes are represented by the ErrorCode enum. Reference types and value types are both supported via the StoredType alias. Use IsSuccess()/IsFailure() to branch logic, and Value() to access the contained value. On failure, a critical log is emitted.