SPH
Classes | Namespaces | Typedefs | Functions | Variables
Outcome.h File Reference

Return value of function that may fail, containing either SUCCEES (true) or error message. More...

#include "objects/wrappers/Optional.h"

Go to the source code of this file.

Classes

struct  SuccessTag
 
struct  FailTag
 
struct  OutcomeTraits< TError >
 Utility functions used within BasicOutcome. More...
 
struct  OutcomeTraits< std::string >
 
class  BasicOutcome< TError >
 Expected-like class that does not contain any value. More...
 

Namespaces

 Detail
 

Typedefs

using Outcome = BasicOutcome< std::string >
 Alias for string error message. More...
 

Functions

INLINE void Detail::printArgs (std::stringstream &)
 
template<typename T0 , typename... TArgs>
INLINE void Detail::printArgs (std::stringstream &ss, T0 &&t0, TArgs &&... args)
 
template<typename... TArgs>
INLINE Outcome makeFailed (TArgs &&... args)
 Constructs failed object with error message. More...
 
template<typename... TArgs>
INLINE Outcome makeOutcome (const bool condition, TArgs &&... args)
 Constructs outcome object given the condition. More...
 

Variables

const SuccessTag SUCCESS
 Global constant for successful outcome. More...
 

Detailed Description

Return value of function that may fail, containing either SUCCEES (true) or error message.

Author
Pavel Sevecek (sevecek ar sirrah.troja.mff.cuni.cz)
Date
2016-2021

Definition in file Outcome.h.

Typedef Documentation

◆ Outcome

using Outcome = BasicOutcome<std::string>

Alias for string error message.

Definition at line 138 of file Outcome.h.

Function Documentation

◆ makeFailed()

template<typename... TArgs>
INLINE Outcome makeFailed ( TArgs &&...  args)

Constructs failed object with error message.

Error message is constructed by converting arguments to string and concatenating them.

Definition at line 157 of file Outcome.h.

◆ makeOutcome()

template<typename... TArgs>
INLINE Outcome makeOutcome ( const bool  condition,
TArgs &&...  args 
)

Constructs outcome object given the condition.

If condition equals false, print error message using argument list.

Definition at line 168 of file Outcome.h.

Variable Documentation

◆ SUCCESS

const SuccessTag SUCCESS

Global constant for successful outcome.

Definition at line 141 of file Outcome.h.