HAL  v4.5.0-83-g30c8f0afc
The Hardware Analyzer - a comprehensive reverse engineering and manipulation framework for gate-level netlists.
hal::Result< T > Class Template Referencefinal

#include <hal_core/utilities/result.h>

Collaboration diagram for hal::Result< T >:
Collaboration graph

Public Member Functions

template<typename... Args, typename U = T, typename std::enable_if_t< std::is_same_v< U, void >, int > = 0>
 Result (result_constructor_type::OK)
 
template<typename... Args, typename U = T, typename std::enable_if_t<!std::is_same_v< U, void >, int > = 0>
 Result (result_constructor_type::OK, const T &value)
 
template<typename... Args, typename U = T, typename std::enable_if_t<!std::is_same_v< U, void >, int > = 0>
 Result (result_constructor_type::OK, std::remove_reference_t< T > &&value)
 
 Result (result_constructor_type::ER, const Error &error)
 
bool operator== (const Result< T > &other)
 
bool operator!= (const Result< T > &other)
 
bool is_ok () const
 
bool is_error () const
 
template<typename U = T, typename std::enable_if_t<!std::is_same_v< U, void >, int > = 0>
const T & get () const
 
template<typename U = T, typename std::enable_if_t<!std::is_same_v< U, void >, int > = 0>
T && get ()
 
const Errorget_error () const
 
Error && get_error ()
 
template<typename U , typename std::enable_if_t<!std::is_same_v< U, void >, int > = 0>
Result< U > map (const std::function< Result< U >(const T &)> &f) const
 
template<typename U , typename std::enable_if_t<!std::is_same_v< U, void >, int > = 0>
Result< U > map (const std::function< Result< U >(T &&)> &f)
 

Static Public Member Functions

template<typename... Args, typename U = T, typename std::enable_if_t<!std::is_same_v< U, void >, int > = 0>
static Result< T > Ok (const T &value)
 
template<typename... Args, typename U = T, typename std::enable_if_t<!std::is_same_v< U, void >, int > = 0>
static Result< T > Ok (std::remove_reference_t< T > &&value)
 

Detailed Description

template<typename T>
class hal::Result< T >

Definition at line 70 of file result.h.

Constructor & Destructor Documentation

◆ Result() [1/4]

template<typename T >
template<typename... Args, typename U = T, typename std::enable_if_t< std::is_same_v< U, void >, int > = 0>
hal::Result< T >::Result ( result_constructor_type::OK  )
inline

Definition at line 77 of file result.h.

◆ Result() [2/4]

template<typename T >
template<typename... Args, typename U = T, typename std::enable_if_t<!std::is_same_v< U, void >, int > = 0>
hal::Result< T >::Result ( result_constructor_type::OK  ,
const T &  value 
)
inline

Definition at line 82 of file result.h.

◆ Result() [3/4]

template<typename T >
template<typename... Args, typename U = T, typename std::enable_if_t<!std::is_same_v< U, void >, int > = 0>
hal::Result< T >::Result ( result_constructor_type::OK  ,
std::remove_reference_t< T > &&  value 
)
inline

Definition at line 87 of file result.h.

◆ Result() [4/4]

template<typename T >
hal::Result< T >::Result ( result_constructor_type::ER  ,
const Error error 
)
inline

Definition at line 91 of file result.h.

References hal::error.

Member Function Documentation

◆ get() [1/2]

template<typename T >
template<typename U = T, typename std::enable_if_t<!std::is_same_v< U, void >, int > = 0>
T&& hal::Result< T >::get ( )
inline

Get the value of the result. It is up to the user to check whether the result is valid using Result::is_ok() beforehand.

Template Parameters
U- The type of the result value.
Returns
The result value.

Definition at line 179 of file result.h.

References hal::T.

◆ get() [2/2]

template<typename T >
template<typename U = T, typename std::enable_if_t<!std::is_same_v< U, void >, int > = 0>
const T& hal::Result< T >::get ( ) const
inline

Get the value of the result. It is up to the user to check whether the result is valid using Result::is_ok() beforehand.

Template Parameters
U- The type of the result value.
Returns
The result value.

Definition at line 166 of file result.h.

References hal::T.

◆ get_error() [1/2]

template<typename T >
Error&& hal::Result< T >::get_error ( )
inline

Get the error of the result. It is up to the user to check whether the result is an error using Result::is_error() beforehand.

Returns
The error.

Definition at line 201 of file result.h.

◆ get_error() [2/2]

template<typename T >
const Error& hal::Result< T >::get_error ( ) const
inline

Get the error of the result. It is up to the user to check whether the result is an error using Result::is_error() beforehand.

Returns
The error.

Definition at line 190 of file result.h.

◆ is_error()

template<typename T >
bool hal::Result< T >::is_error ( ) const
inline

Check whether the result is an error.

Returns
true if the result is an error, false otherwise.

Definition at line 153 of file result.h.

◆ is_ok()

template<typename T >
bool hal::Result< T >::is_ok ( ) const
inline

Check whether the result is valid, i.e., not an error.

Returns
true if the result is valid, false otherwise.

Definition at line 143 of file result.h.

◆ map() [1/2]

template<typename T >
template<typename U , typename std::enable_if_t<!std::is_same_v< U, void >, int > = 0>
Result<U> hal::Result< T >::map ( const std::function< Result< U >(const T &)> &  f) const
inline

Map the result to a different user-defined data type using the provided mapping function.

Template Parameters
U- The target data type.
Parameters
[in]f- The mapping function.
Returns
The result mapped to the target data type.

Definition at line 214 of file result.h.

References ERR.

◆ map() [2/2]

template<typename T >
template<typename U , typename std::enable_if_t<!std::is_same_v< U, void >, int > = 0>
Result<U> hal::Result< T >::map ( const std::function< Result< U >(T &&)> &  f)
inline

Map the result to a different user-defined data type using the provided mapping function.

Template Parameters
U- The target data type.
Parameters
[in]f- The mapping function.
Returns
The result mapped to the target data type.

Definition at line 234 of file result.h.

References ERR.

◆ Ok() [1/2]

template<typename T >
template<typename... Args, typename U = T, typename std::enable_if_t<!std::is_same_v< U, void >, int > = 0>
static Result<T> hal::Result< T >::Ok ( const T &  value)
inlinestatic

Construct a valid result carrying a result value.

Parameters
[in]value- The result value.
Returns
The result.

Definition at line 102 of file result.h.

References OK.

◆ Ok() [2/2]

template<typename T >
template<typename... Args, typename U = T, typename std::enable_if_t<!std::is_same_v< U, void >, int > = 0>
static Result<T> hal::Result< T >::Ok ( std::remove_reference_t< T > &&  value)
inlinestatic

Construct a valid result carrying a result value.

Parameters
[in]value- The result value.
Returns
The result.

Definition at line 111 of file result.h.

References OK.

◆ operator!=()

template<typename T >
bool hal::Result< T >::operator!= ( const Result< T > &  other)
inline

Check whether two results are unequal.

Parameters
[in]other- The result to compare against.
Returns
true if both results are unequal, false otherwise.

Definition at line 133 of file result.h.

◆ operator==()

template<typename T >
bool hal::Result< T >::operator== ( const Result< T > &  other)
inline

Check whether two results are equal.

Parameters
[in]other- The result to compare against.
Returns
true if both results are equal, false otherwise.

Definition at line 122 of file result.h.


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