libpromeki main
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
result.h File Reference
Include dependency graph for result.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

template<typename T >
using Result = Pair< T, Error >
 Convenience alias for fallible return types.
 

Functions

template<typename T >
Result< TmakeResult (T value)
 Creates a successful Result wrapping value.
 
template<typename T >
Result< TmakeError (Error err)
 Creates an error Result with a default-constructed value.
 
template<typename T >
const Tvalue (const Result< T > &r)
 Returns the value from a Result.
 
template<typename T >
const Errorerror (const Result< T > &r)
 Returns the error from a Result.
 
template<typename T >
bool isOk (const Result< T > &r)
 Returns true if the Result is successful (Error::Ok).
 
template<typename T >
bool isError (const Result< T > &r)
 Returns true if the Result has an error.
 

Detailed Description

See LICENSE file in the project root folder for license information.

Function Documentation

◆ error()

template<typename T >
const Error & error ( const Result< T > &  r)

Returns the error from a Result.

Template Parameters
TThe value type.
Parameters
rThe Result to query.
Returns
The Error.

◆ isError()

template<typename T >
bool isError ( const Result< T > &  r)

Returns true if the Result has an error.

Template Parameters
TThe value type.
Parameters
rThe Result to query.
Returns
True if error.

◆ isOk()

template<typename T >
bool isOk ( const Result< T > &  r)

Returns true if the Result is successful (Error::Ok).

Template Parameters
TThe value type.
Parameters
rThe Result to query.
Returns
True if no error.

◆ makeError()

template<typename T >
Result< T > makeError ( Error  err)

Creates an error Result with a default-constructed value.

Template Parameters
TThe value type.
Parameters
errThe error code.
Returns
A Result with default-constructed T and the given error.

◆ makeResult()

template<typename T >
Result< T > makeResult ( T  value)

Creates a successful Result wrapping value.

Template Parameters
TThe value type.
Parameters
valueThe value to wrap.
Returns
A Result with the value and Error::Ok.

◆ value()

template<typename T >
const T & value ( const Result< T > &  r)

Returns the value from a Result.

Template Parameters
TThe value type.
Parameters
rThe Result to query.
Returns
Const reference to the value.