Resilient
Public Types | Public Member Functions | Related Functions | List of all members
resilient::ICallResult< T > Class Template Referenceabstract

Interface to represent the result of calling a detected function. More...

#include <callresult.hpp>

Inherited by resilient::detail::OperationResult< T >.

Public Types

using ConstRefType = const std::decay_t< T > &
 Convenience type alias for a const ref to type T.
 

Public Member Functions

virtual void consumeException ()=0
 Consume (signal as handled) an exception if the detected threw one. More...
 
virtual bool isException () const =0
 Whether the detected function invokation threw an exception. More...
 
virtual const std::exception_ptr & getException () const =0
 Get a pointer of the thrown exception. More...
 
virtual ConstRefType getResult () const =0
 Access the result of the detected function. More...
 

Related Functions

(Note that these are not member functions.)

template<typename Visitor , typename T >
 decltype (auto) constexpr resilient::visit(Visitor &&visitor, ICallResult< T > &callresult)
 Visit the ICallResult<T> as if it was a variant. More...
 

Detailed Description

template<typename T>
class resilient::ICallResult< T >

Interface to represent the result of calling a detected function.

A detected function invokation can result in either:

Template Parameters
TThe type returned by the detected function.

Member Function Documentation

template<typename T >
virtual void resilient::ICallResult< T >::consumeException ( )
pure virtual

Consume (signal as handled) an exception if the detected threw one.

It's invalid to call this function if isException() returns false.

template<typename T >
virtual const std::exception_ptr& resilient::ICallResult< T >::getException ( ) const
pure virtual

Get a pointer of the thrown exception.

It's invalid to call this function is isException() returns false.

Returns
const std::exception_ptr&
template<typename T >
virtual ConstRefType resilient::ICallResult< T >::getResult ( ) const
pure virtual

Access the result of the detected function.

It's invalid to call this function if isException() returns true.

Returns
ConstRefType The value returned by the detected function.
template<typename T >
virtual bool resilient::ICallResult< T >::isException ( ) const
pure virtual

Whether the detected function invokation threw an exception.

Returns
true An exception was thrown.
false An result was returned

Friends And Related Function Documentation

template<typename Visitor , typename T >
decltype ( Visitor &&  visitor,
ICallResult< T > &  callresult 
)
related

Visit the ICallResult<T> as if it was a variant.

Template Parameters
VisitorThe type of the object which defines the overloaded operator() to be called.
TThe type returned by the detected function.
Parameters
visitorThe object called with either the std::exception_ptr or const T&.
callresultThe callresult object.
Returns
The type returned by the visitor.

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