gempyre  1.7.1
GempyreUtils::Result< R, E > Struct Template Reference

similar as std::optional, but with error info (not 100% same, add delta if needed). More...

#include <gempyre_utils.h>

Inheritance diagram for GempyreUtils::Result< R, E >:
[legend]
Collaboration diagram for GempyreUtils::Result< R, E >:
[legend]

Public Types

using value_type = R
 std compatibility
 
using error_type = E
 std compatibility
 

Public Member Functions

constexpr Result (R &&r)
 
constexpr Result (Err &&e)
 
constexpr Result (const R &r)
 
constexpr Result (const Err &e)
 
constexpr Resultoperator= (R &&r)
 
constexpr Resultoperator= (Err &&e)
 
constexpr Resultoperator= (const R &r)
 
constexpr Resultoperator= (const Err &e)
 
constexpr operator bool () const
 true if has value
 
constexpr operator std::optional< R > () const
 get as optional
 
constexpr bool has_value () const
 true is has value
 
constexpr const R & value () const
 get value if available
 
constexpr const E & error () const
 get error if not value
 
constexpr R & value ()
 get value if available
 
constexpr R & operator* ()
 get ref to value
 
constexpr const R & operator* () const
 get ref to value
 
constexpr R * operator-> ()
 get pointer to value
 
constexpr const R * operator-> () const
 get pointer to value
 

Static Public Member Functions

constexpr static auto make_error (const E &e)
 helper to make error value More...
 
constexpr static auto make_error (E &&e)
 helper to make error value More...
 
constexpr static auto make_error ()
 helper to make error value, valid only if error has a default constructor More...
 
constexpr static auto ok ()
 helper to make valid value, valid only if result has a default constructor More...
 

Detailed Description

template<typename R, typename E = std::string>
struct GempyreUtils::Result< R, E >

similar as std::optional, but with error info (not 100% same, add delta if needed).

Constructor & Destructor Documentation

◆ Result() [1/4]

template<typename R , typename E = std::string>
constexpr GempyreUtils::Result< R, E >::Result ( R &&  r)
inlineconstexpr
Parameters
r

◆ Result() [2/4]

template<typename R , typename E = std::string>
constexpr GempyreUtils::Result< R, E >::Result ( Err &&  e)
inlineconstexpr
Parameters
e

◆ Result() [3/4]

template<typename R , typename E = std::string>
constexpr GempyreUtils::Result< R, E >::Result ( const R &  r)
inlineconstexpr
Parameters
r

◆ Result() [4/4]

template<typename R , typename E = std::string>
constexpr GempyreUtils::Result< R, E >::Result ( const Err &  e)
inlineconstexpr
Parameters
e

Member Function Documentation

◆ make_error() [1/3]

template<typename R , typename E = std::string>
constexpr static auto GempyreUtils::Result< R, E >::make_error ( )
inlinestaticconstexpr

helper to make error value, valid only if error has a default constructor

Returns

◆ make_error() [2/3]

template<typename R , typename E = std::string>
constexpr static auto GempyreUtils::Result< R, E >::make_error ( const E &  e)
inlinestaticconstexpr

helper to make error value

Parameters
e
Returns

◆ make_error() [3/3]

template<typename R , typename E = std::string>
constexpr static auto GempyreUtils::Result< R, E >::make_error ( E &&  e)
inlinestaticconstexpr

helper to make error value

Parameters
e
Returns

◆ ok()

template<typename R , typename E = std::string>
constexpr static auto GempyreUtils::Result< R, E >::ok ( )
inlinestaticconstexpr

helper to make valid value, valid only if result has a default constructor

Returns

◆ operator=() [1/4]

template<typename R , typename E = std::string>
constexpr Result& GempyreUtils::Result< R, E >::operator= ( const Err &  e)
inlineconstexpr
Parameters
e
Returns

◆ operator=() [2/4]

template<typename R , typename E = std::string>
constexpr Result& GempyreUtils::Result< R, E >::operator= ( const R &  r)
inlineconstexpr
Parameters
r
Returns

◆ operator=() [3/4]

template<typename R , typename E = std::string>
constexpr Result& GempyreUtils::Result< R, E >::operator= ( Err &&  e)
inlineconstexpr
Parameters
e
Returns

◆ operator=() [4/4]

template<typename R , typename E = std::string>
constexpr Result& GempyreUtils::Result< R, E >::operator= ( R &&  r)
inlineconstexpr
Parameters
r
Returns


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