![]() |
LeechCraft
0.6.70-15082-g543737046d
Modular cross-platform feature rich live environment.
|
A peir of two functions, typically a continuation and an error handler. More...
#include "eithercont.h"
Public Member Functions | |
EitherCont ()=default | |
Default-constructs the continuation with uninitialized functions. More... | |
template<typename L , typename R > | |
EitherCont (const L &l, const R &r) | |
Sets the left and right functions to l and r. More... | |
operator bool () const | |
Checks if both functions are initialized. More... | |
template<typename... Args> | |
auto | Left (Args &&... args) const |
Invoke the left function and return its result. More... | |
template<typename... Args> | |
auto | Right (Args &&... args) const |
Invoke the right function and return its result. More... | |
A peir of two functions, typically a continuation and an error handler.
Inspired by Haskell's Data.Either, the functions contained in EitherCont are called left and right respectively.
The common convention is to store the "normal" continuation in the right function, while the left one stores the error handler.
LeftSig | The signature of the left function. |
RightSig | The signature of the right function. |
Definition at line 42 of file eithercont.h.
|
default |
Default-constructs the continuation with uninitialized functions.
|
inline |
Sets the left and right functions to l and r.
L | The type of the left functor which should be used to initialize the left function (must be convertible to LeftSig). |
R | The type of the right functor which should be used to initialize the left function (must be convertible to LeftSig). |
Definition at line 70 of file eithercont.h.
|
inline |
Invoke the left function and return its result.
Invokes the left function forwarding args of type Args (which may be different from the types in LeftSig, but convertible to them), and returns its result.
[in] | args | The arguments to forward to the left function. |
Args | The types of arguments to pass to the left function. |
Definition at line 102 of file eithercont.h.
|
inlineexplicit |
Checks if both functions are initialized.
Calling any function on an object for which this function returns false leads to undefined behavior.
Definition at line 83 of file eithercont.h.
|
inline |
Invoke the right function and return its result.
Invokes the right function forwarding args of type Args (which may be different from the types in RightSig, but convertible to them), and returns its result.
[in] | args | The arguments to forward to the right function. |
Args | The types of arguments to pass to the right function. |
Definition at line 121 of file eithercont.h.