FastLED 3.9.15
Loading...
Searching...
No Matches
fl::expected< T, E > Class Template Reference

Detailed Description

template<typename T, typename E>
class fl::expected< T, E >

expected type for operations that can fail (C++23-style)

Explicit error handling without exceptions, using fl::variant for safe storage

Template Parameters
TThe type of the successful value
EThe type of the error code (must be an enum or integral type)

Definition at line 79 of file expected.h.

#include <expected.h>

+ Inheritance diagram for fl::expected< T, E >:

Public Member Functions

 expected () FL_NOEXCEPT
 Default constructor (creates error state)
 
 expected (expected &&other) FL_NOEXCEPT=default
 Move constructor (defaulted - variant handles it)
 
 ~expected () FL_NOEXCEPT=default
 Destructor (defaulted - variant handles cleanup)
 
error () const FL_NOEXCEPT
 Get error code (only meaningful if !ok())
 
bool has_value () const FL_NOEXCEPT
 Check if operation succeeded (alias for ok())
 
const char * message () const FL_NOEXCEPT
 Get error message (only meaningful if !ok())
 
bool ok () const FL_NOEXCEPT
 Check if operation succeeded.
 
 operator bool () const FL_NOEXCEPT
 Explicit conversion to bool for contextual evaluation.
 
expectedoperator= (expected &&other) FL_NOEXCEPT=default
 Move assignment (defaulted - variant handles it)
 
const T & value () const FL_NOEXCEPT
 
T & value () FL_NOEXCEPT
 Get value (only valid if ok() == true)
 

Static Public Member Functions

static expected failure (E err, const char *msg=nullptr) FL_NOEXCEPT
 Create error result.
 
static expected success (T value) FL_NOEXCEPT
 Create successful result.
 

Private Member Functions

 expected (const expected &) FL_NOEXCEPT=delete
 
expectedoperator= (const expected &) FL_NOEXCEPT=delete
 

Private Attributes

fl::variant< T, ErrorInfo< E > > mData
 

The documentation for this class was generated from the following file: