Woman, Life, Freedom


Adaptive AUTOSAR
ARA public interface header documentation
ara::core::Result< void, E > Class Template Referencefinal

A wrapper around the callee's possible error. More...

#include <result.h>

Public Types

using value_type = void
 Void value type alias.
 
using error_type = E
 Result error type alias.
 

Public Member Functions

 Result (const E &e) noexcept(std::is_nothrow_copy_constructible< E >::value)
 
 Result (E &&e) noexcept(std::is_nothrow_move_constructible< E >::value)
 
 Result (const Result &other) noexcept(std::is_nothrow_copy_assignable< E >::value)
 
 Result (Result &&other) noexcept(std::is_nothrow_move_assignable< E >::value)
 
Resultoperator= (Result const &other) noexcept(std::is_nothrow_copy_assignable< E >::value)
 
Resultoperator= (Result &&other) noexcept(std::is_nothrow_move_assignable< E >::value)
 
template<typename... Args>
void EmplaceError (Args &&...args)
 Construct a new error from the give argument(s) and assign it to the instance error. More...
 
void Swap (Result &other) noexcept(std::is_nothrow_move_assignable< E >::value)
 Swap the current instance with another one. More...
 
constexpr bool HasValue () const noexcept
 Indicate whether the instance contains an error or not. More...
 
constexpr operator bool () const noexcept
 
constexpr void operator* () const noexcept
 
constexpr void operator-> () const noexcept
 
constexpr void Value () const noexcept
 The function does nothing.
 
const E & Error () const &
 Get instance possible error. More...
 
E && Error () &&
 Get instance possible error. More...
 
Optional< E > Err () const &
 Get optional instance error. More...
 
Optional< E > Err () &&
 Get optional instance error. More...
 
template<typename U >
void ValueOr (U &&defaultValue) const noexcept
 The function does nothing.
 
template<typename G >
ErrorOr (G &&defaultError) const &
 Get the instance error or the default error. More...
 
template<typename G >
ErrorOr (G &&defaultError) &&
 Get the instance error or the default error. More...
 
template<typename G >
bool CheckError (G &&error) const
 Check an error with the instance error. More...
 
void ValueOrThrow () const noexcept(false)
 Throw an exception. More...
 
template<typename F >
void Resolve (F &&f) const
 Invoke a callable. More...
 
template<typename F >
auto Bind (F &&f) const -> Result< decltype(f()), E >
 Create a new Result by invoking a callable. More...
 
template<typename... Args>
Result< void, E > FromError (Args &&...args)
 

Static Public Member Functions

static Result FromValue () noexcept
 Void Result factory. More...
 
static Result FromError (const E &e) noexcept(std::is_nothrow_copy_constructible< E >::value)
 Result factory by copying its error. More...
 
static Result FromError (E &&e) noexcept(std::is_nothrow_move_constructible< E >::value)
 Result factory by moving its error. More...
 
template<typename... Args>
static Result FromError (Args &&...args)
 Construct a new error from the give argument(s) and assign it to the instance error. More...
 

Detailed Description

template<typename E>
class ara::core::Result< void, E >

A wrapper around the callee's possible error.

Template Parameters
ECallee's possible error type

Member Function Documentation

◆ Bind()

template<typename E >
template<typename F >
auto ara::core::Result< void, E >::Bind ( F &&  f) const -> Result<decltype(f()), E>
inline

Create a new Result by invoking a callable.

Template Parameters
FCallable type
Parameters
fCallable that returns a new Result
Returns
Callable result if the instance does not contain an error, otherwise a new Result with the copied instance error

◆ CheckError()

template<typename E >
template<typename G >
bool ara::core::Result< void, E >::CheckError ( G &&  error) const
inline

Check an error with the instance error.

Template Parameters
GInput error type
Returns
True if the input error equals the instance error, otherwise false

◆ EmplaceError()

template<typename E >
template<typename... Args>
void ara::core::Result< void, E >::EmplaceError ( Args &&...  args)
inline

Construct a new error from the give argument(s) and assign it to the instance error.

Parameters
argsArgument(s) to construct a new error

◆ Err() [1/2]

template<typename E >
Optional< E > ara::core::Result< void, E >::Err ( ) &&
inline

Get optional instance error.

Returns
Optional error

◆ Err() [2/2]

template<typename E >
Optional< E > ara::core::Result< void, E >::Err ( ) const &
inline

Get optional instance error.

Returns
Optional error

◆ Error() [1/2]

template<typename E >
E && ara::core::Result< void, E >::Error ( ) &&
inline

Get instance possible error.

Returns
Movable error
Exceptions
std::runtime_errorThrows if there is no error

◆ Error() [2/2]

template<typename E >
const E & ara::core::Result< void, E >::Error ( ) const &
inline

Get instance possible error.

Returns
Copied error
Exceptions
std::runtime_errorThrows if there is no error

◆ ErrorOr() [1/2]

template<typename E >
template<typename G >
E ara::core::Result< void, E >::ErrorOr ( G &&  defaultError) &&
inline

Get the instance error or the default error.

Template Parameters
GDefault error type
Parameters
defaultErrorError to be return in absence of the instance error
Returns
Instance error if exists, otherwise the default error

◆ ErrorOr() [2/2]

template<typename E >
template<typename G >
E ara::core::Result< void, E >::ErrorOr ( G &&  defaultError) const &
inline

Get the instance error or the default error.

Template Parameters
GDefault error type
Parameters
defaultErrorError to be return in absence of the instance error
Returns
Instance error if exists, otherwise the default error

◆ FromError() [1/3]

template<typename E >
template<typename... Args>
static Result ara::core::Result< void, E >::FromError ( Args &&...  args)
static

Construct a new error from the give argument(s) and assign it to the instance error.

Parameters
argsArgument(s) to construct a new error

◆ FromError() [2/3]

template<typename E >
Result< void, E > ara::core::Result< void, E >::FromError ( const E &  e)
staticnoexcept

Result factory by copying its error.

Parameters
eResult error
Returns
Created Result from the error

◆ FromError() [3/3]

template<typename E >
Result< void, E > ara::core::Result< void, E >::FromError ( E &&  e)
staticnoexcept

Result factory by moving its error.

Parameters
eResult error
Returns
Created Result from the error

◆ FromValue()

template<typename E >
Result< void, E > ara::core::Result< void, E >::FromValue
staticnoexcept

Void Result factory.

Returns
Default void Result

◆ HasValue()

template<typename E >
constexpr bool ara::core::Result< void, E >::HasValue ( ) const
inlineconstexprnoexcept

Indicate whether the instance contains an error or not.

Returns
True if the instance has no error, otherwise false

◆ operator bool()

template<typename E >
constexpr ara::core::Result< void, E >::operator bool ( ) const
inlineexplicitconstexprnoexcept
Returns
True if the instance has no error, otherwise false

◆ Resolve()

template<typename E >
template<typename F >
void ara::core::Result< void, E >::Resolve ( F &&  f) const
inline

Invoke a callable.

Template Parameters
FCallable type
Parameters
fCallable to be invoked

◆ Swap()

template<typename E >
void ara::core::Result< void, E >::Swap ( Result< void, E > &  other)
inlinenoexcept

Swap the current instance with another one.

Parameters
otherAnother Result for swapping

◆ ValueOrThrow()

template<typename E >
void ara::core::Result< void, E >::ValueOrThrow ( ) const
inlinenoexcept

Throw an exception.

Exceptions
std::runtime_errorThrows always due to the fact that the instance does not contain a value