LogViewer
A modern log viewer with AI-assisted analysis (Qt 6)
Loading...
Searching...
No Matches
util::Result< T, E > Class Template Reference

#include <Result.hpp>

Collaboration diagram for util::Result< T, E >:
Collaboration graph

Public Member Functions

bool isOk () const noexcept
 
bool isErr () const noexcept
 
 operator bool () const noexcept
 
T unwrap ()
 
T unwrapOr (T defaultValue) const
 
template<typename F >
T unwrapOrElse (F &&fn)
 
const E & error () const
 
template<typename F >
auto map (F &&fn)
 
template<typename F >
auto mapErr (F &&fn)
 
template<typename F >
auto andThen (F &&fn) -> std::invoke_result_t< F, T >
 
template<typename F >
Result orElse (F &&fn)
 
std::optional< T > ok () const
 
std::optional< E > err () const
 

Static Public Member Functions

static Result Ok (T value)
 
static Result Err (E error)
 

Private Member Functions

 Result (std::expected< T, E > data)
 

Private Attributes

std::expected< T, E > m_data
 

Detailed Description

template<typename T, typename E>
class util::Result< T, E >

A Result<T,E> type backed by std::expected<T,E> (C++23). Carries either a success value (Ok) or an error (Err).

Constructor & Destructor Documentation

◆ Result()

template<typename T , typename E >
util::Result< T, E >::Result ( std::expected< T, E >  data)
inlineexplicitprivate

Member Function Documentation

◆ andThen()

template<typename T , typename E >
template<typename F >
auto util::Result< T, E >::andThen ( F &&  fn) -> std::invoke_result_t<F, T>
inline

◆ err()

template<typename T , typename E >
std::optional< E > util::Result< T, E >::err ( ) const
inline

◆ Err()

template<typename T , typename E >
static Result util::Result< T, E >::Err ( E  error)
inlinestatic
Here is the caller graph for this function:

◆ error()

template<typename T , typename E >
const E & util::Result< T, E >::error ( ) const
inline

◆ isErr()

template<typename T , typename E >
bool util::Result< T, E >::isErr ( ) const
inlinenoexcept

◆ isOk()

template<typename T , typename E >
bool util::Result< T, E >::isOk ( ) const
inlinenoexcept

◆ map()

template<typename T , typename E >
template<typename F >
auto util::Result< T, E >::map ( F &&  fn)
inline
Here is the call graph for this function:

◆ mapErr()

template<typename T , typename E >
template<typename F >
auto util::Result< T, E >::mapErr ( F &&  fn)
inline
Here is the call graph for this function:

◆ ok()

template<typename T , typename E >
std::optional< T > util::Result< T, E >::ok ( ) const
inline

◆ Ok()

template<typename T , typename E >
static Result util::Result< T, E >::Ok ( T  value)
inlinestatic
Here is the caller graph for this function:

◆ operator bool()

template<typename T , typename E >
util::Result< T, E >::operator bool ( ) const
inlineexplicitnoexcept

◆ orElse()

template<typename T , typename E >
template<typename F >
Result util::Result< T, E >::orElse ( F &&  fn)
inline
Here is the call graph for this function:

◆ unwrap()

template<typename T , typename E >
T util::Result< T, E >::unwrap ( )
inline

◆ unwrapOr()

template<typename T , typename E >
T util::Result< T, E >::unwrapOr ( T  defaultValue) const
inline

◆ unwrapOrElse()

template<typename T , typename E >
template<typename F >
T util::Result< T, E >::unwrapOrElse ( F &&  fn)
inline

Member Data Documentation

◆ m_data

template<typename T , typename E >
std::expected<T,E> util::Result< T, E >::m_data
private

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