Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
pulp::runtime::Result< T, E > Class Template Reference

Result<T, E> — either holds a T or an E, never both. More...

#include <result.hpp>

Public Types

using value_type = T
using error_type = E

Public Member Functions

 Result ()
 Result (Ok< T > ok)
 Result (Err< E > err)
 Result (const Result &other)
 Result (Result &&other) noexcept(std::is_nothrow_move_constructible_v< T > &&std::is_nothrow_move_constructible_v< E >)
Result & operator= (const Result &other)
Result & operator= (Result &&other) noexcept(std::is_nothrow_move_constructible_v< T > &&std::is_nothrow_move_constructible_v< E >)
 ~Result ()
bool has_value () const noexcept
 operator bool () const noexcept
bool is_err () const noexcept
T & value () &
const T & value () const &
T && value () &&
T & operator* () &
const T & operator* () const &
T * operator-> ()
const T * operator-> () const
template<typename U>
T value_or (U &&fallback) const &
 Return the held value, or fallback when this is an error.
E & error () &
const E & error () const &
E && error () &&

Detailed Description

template<typename T, typename E>
class pulp::runtime::Result< T, E >

Result<T, E> — either holds a T or an E, never both.

Inspired by Rust's Result and std::expected. T and E must be distinct types (avoids construct-from-ambiguity).

Member Typedef Documentation

◆ error_type

template<typename T, typename E>
using pulp::runtime::Result< T, E >::error_type = E

◆ value_type

template<typename T, typename E>
using pulp::runtime::Result< T, E >::value_type = T

Constructor & Destructor Documentation

◆ Result() [1/5]

template<typename T, typename E>
pulp::runtime::Result< T, E >::Result ( )
inline

◆ Result() [2/5]

template<typename T, typename E>
pulp::runtime::Result< T, E >::Result ( Ok< T > ok)
inline

◆ Result() [3/5]

template<typename T, typename E>
pulp::runtime::Result< T, E >::Result ( Err< E > err)
inline

◆ Result() [4/5]

template<typename T, typename E>
pulp::runtime::Result< T, E >::Result ( const Result< T, E > & other)
inline

◆ Result() [5/5]

template<typename T, typename E>
pulp::runtime::Result< T, E >::Result ( Result< T, E > && other)
inlinenoexcept

◆ ~Result()

template<typename T, typename E>
pulp::runtime::Result< T, E >::~Result ( )
inline

Member Function Documentation

◆ error() [1/3]

template<typename T, typename E>
E & pulp::runtime::Result< T, E >::error ( ) &
inline

◆ error() [2/3]

template<typename T, typename E>
E && pulp::runtime::Result< T, E >::error ( ) &&
inline

◆ error() [3/3]

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

◆ has_value()

template<typename T, typename E>
bool pulp::runtime::Result< T, E >::has_value ( ) const
inlinenoexcept

◆ is_err()

template<typename T, typename E>
bool pulp::runtime::Result< T, E >::is_err ( ) const
inlinenoexcept

◆ operator bool()

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

◆ operator*() [1/2]

template<typename T, typename E>
T & pulp::runtime::Result< T, E >::operator* ( ) &
inline

◆ operator*() [2/2]

template<typename T, typename E>
const T & pulp::runtime::Result< T, E >::operator* ( ) const &
inline

◆ operator->() [1/2]

template<typename T, typename E>
T * pulp::runtime::Result< T, E >::operator-> ( )
inline

◆ operator->() [2/2]

template<typename T, typename E>
const T * pulp::runtime::Result< T, E >::operator-> ( ) const
inline

◆ operator=() [1/2]

template<typename T, typename E>
Result & pulp::runtime::Result< T, E >::operator= ( const Result< T, E > & other)
inline

◆ operator=() [2/2]

template<typename T, typename E>
Result & pulp::runtime::Result< T, E >::operator= ( Result< T, E > && other)
inlinenoexcept

◆ value() [1/3]

template<typename T, typename E>
T & pulp::runtime::Result< T, E >::value ( ) &
inline

◆ value() [2/3]

template<typename T, typename E>
T && pulp::runtime::Result< T, E >::value ( ) &&
inline

◆ value() [3/3]

template<typename T, typename E>
const T & pulp::runtime::Result< T, E >::value ( ) const &
inline

◆ value_or()

template<typename T, typename E>
template<typename U>
T pulp::runtime::Result< T, E >::value_or ( U && fallback) const &
inline

Return the held value, or fallback when this is an error.


The documentation for this class was generated from the following file:
  • /home/runner/work/pulp/pulp/core/runtime/include/pulp/runtime/result.hpp