MAX22200 Driver 0.1.0
API reference
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
max22200::Result< T > Struct Template Reference

The value of a call, or why there is none. More...

#include <max22200_types.hpp>

Public Member Functions

constexpr bool ok () const noexcept
 
constexpr operator bool () const noexcept
 

Static Public Member Functions

static constexpr Result Success (T v) noexcept
 A successful result.
 
static constexpr Result Failure (Error e) noexcept
 A failed result.
 

Public Attributes

T value {}
 The value; T{} when the call failed.
 
Error error {Error::Ok}
 Error::Ok on success.
 

Detailed Description

template<typename T>
struct max22200::Result< T >

The value of a call, or why there is none.

Check ok() (or the bool conversion) before reading value; on failure value is T{}.

Template Parameters
TThe value type. Result<void> carries only the error.

Member Function Documentation

◆ Failure()

template<typename T >
static constexpr Result max22200::Result< T >::Failure ( Error  e)
inlinestaticconstexprnoexcept

A failed result.

Parameters
eWhy it failed; never Error::Ok.
Returns
{T{}, e}.

◆ ok()

template<typename T >
constexpr bool max22200::Result< T >::ok ( ) const
inlineconstexprnoexcept
Returns
true when the call succeeded.

◆ operator bool()

template<typename T >
constexpr max22200::Result< T >::operator bool ( ) const
inlineexplicitconstexprnoexcept
Returns
true when the call succeeded.

◆ Success()

template<typename T >
static constexpr Result max22200::Result< T >::Success ( T  v)
inlinestaticconstexprnoexcept

A successful result.

Parameters
vThe value.
Returns
{v, Error::Ok}.

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