tenno 0.1.0
Loading...
Searching...
No Matches
tenno::expected< T, E > Class Template Reference

An expected value. More...

#include <expected.hpp>

Public Member Functions

constexpr expected (const T val_in)
 
constexpr expected (const unexpected< E > unex_val)
 
constexpr operator bool () const noexcept
 
constexpr bool operator== (const expected< T, E > &other) const noexcept
 
constexpr bool operator!= (const expected< T, E > &other) const noexcept
 
constexpr auto operator= (const expected< T, E > &other) noexcept -> expected< T, E > &
 
constexpr bool has_value () const noexcept
 
constexpr T value () const noexcept
 
constexpr E error () const noexcept
 
constexpr T value_or (const T default_val) const noexcept
 Returns the value of the expected object or a default value.
 
constexpr E error_or (const E default_err) const noexcept
 Returns the unexpected value of the expected object or a default value.
 

Data Fields

bool has_val
 
const T val
 
const unexpected< E > unex
 

Detailed Description

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

An expected value.

Template Parameters
TThe type of the expected value
EThe type of the unexpected value

Definition at line 37 of file expected.hpp.

Constructor & Destructor Documentation

◆ expected() [1/2]

template<typename T , typename E >
tenno::expected< T, E >::expected ( const T val_in)
inlineconstexpr

Definition at line 44 of file expected.hpp.

◆ expected() [2/2]

template<typename T , typename E >
tenno::expected< T, E >::expected ( const unexpected< E > unex_val)
inlineconstexpr

Definition at line 48 of file expected.hpp.

Member Function Documentation

◆ error()

template<typename T , typename E >
E tenno::expected< T, E >::error ( ) const
inlineconstexprnoexcept

Definition at line 95 of file expected.hpp.

◆ error_or()

template<typename T , typename E >
E tenno::expected< T, E >::error_or ( const E default_err) const
inlineconstexprnoexcept

Returns the unexpected value of the expected object or a default value.

Parameters
default_errThe default value to return if the expected object does not have an unexpected value
Returns
E The unexpected value of the expected object or the default value

Definition at line 125 of file expected.hpp.

◆ has_value()

template<typename T , typename E >
bool tenno::expected< T, E >::has_value ( ) const
inlineconstexprnoexcept

Definition at line 85 of file expected.hpp.

◆ operator bool()

template<typename T , typename E >
tenno::expected< T, E >::operator bool ( ) const
inlineexplicitconstexprnoexcept

Definition at line 53 of file expected.hpp.

◆ operator!=()

template<typename T , typename E >
bool tenno::expected< T, E >::operator!= ( const expected< T, E > & other) const
inlineconstexprnoexcept

Definition at line 71 of file expected.hpp.

◆ operator=()

template<typename T , typename E >
auto tenno::expected< T, E >::operator= ( const expected< T, E > & other) -> expected<T, E> &
inlineconstexprnoexcept

Definition at line 76 of file expected.hpp.

◆ operator==()

template<typename T , typename E >
bool tenno::expected< T, E >::operator== ( const expected< T, E > & other) const
inlineconstexprnoexcept

Definition at line 58 of file expected.hpp.

◆ value()

template<typename T , typename E >
T tenno::expected< T, E >::value ( ) const
inlineconstexprnoexcept

Definition at line 90 of file expected.hpp.

◆ value_or()

template<typename T , typename E >
T tenno::expected< T, E >::value_or ( const T default_val) const
inlineconstexprnoexcept

Returns the value of the expected object or a default value.

Parameters
default_valThe default value to return if the expected object does not have a value
Returns
T The value of the expected object or the default value

Definition at line 107 of file expected.hpp.

Field Documentation

◆ has_val

template<typename T , typename E >
bool tenno::expected< T, E >::has_val

Definition at line 40 of file expected.hpp.

◆ unex

template<typename T , typename E >
const unexpected<E> tenno::expected< T, E >::unex

Definition at line 42 of file expected.hpp.

◆ val

template<typename T , typename E >
const T tenno::expected< T, E >::val

Definition at line 41 of file expected.hpp.


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