FastLED 3.9.15
Loading...
Searching...
No Matches
expected.h File Reference

Detailed Description

Generic expected<T, E> type for error handling without exceptions.

This is a high-level error handling pattern that provides explicit error handling without exceptions. It's modeled after C++23's std::expected.

Example (with default error type):

expected<int> divide(int a, int b) {
if (b == 0) {
return expected<int>::failure(ResultError::INVALID_ARGUMENT, "Division by zero");
}
return expected<int>::success(a / b);
}
auto result = divide(10, 2);
if (result.ok()) {
int value = result.value();
} else {
ResultError err = result.error();
}
ResultError
Generic error codes for expected type.
Definition expected.h:47
expected< T, E > result
Alias for expected (Rust-style naming)
Definition result.h:31

Example (with custom error type):

enum class MyError { NOT_FOUND, INVALID };
expected<int, MyError> divide(int a, int b) {
if (b == 0) {
return expected<int, MyError>::failure(MyError::INVALID, "Division by zero");
}
return expected<int, MyError>::success(a / b);
}

Definition in file expected.h.

#include "fl/stl/stdint.h"
#include "fl/stl/variant.h"
#include "fl/stl/string.h"
#include "fl/stl/noexcept.h"
+ Include dependency graph for expected.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  fl::ErrorInfo< E >
 Error information for expected type. More...
 
class  fl::expected< T, E >
 expected type for operations that can fail (C++23-style) More...
 
class  fl::expected< void, E >
 Specialization for void (no value to return) More...
 
struct  fl::VoidSuccess
 Dummy type for void expected success state. More...
 

Namespaces

namespace  fl
 Base definition for an LED controller.
 

Enumerations

enum class  fl::ResultError : u8 {
  fl::OK , fl::UNKNOWN , fl::INVALID_ARGUMENT , fl::OUT_OF_RANGE ,
  fl::NOT_INITIALIZED , fl::ALREADY_INITIALIZED , fl::ALLOCATION_FAILED , fl::TIMEOUT ,
  fl::BUSY , fl::NOT_SUPPORTED , fl::IO_ERROR
}
 Generic error codes for expected type. More...
 

Class Documentation

◆ fl::VoidSuccess

struct fl::VoidSuccess