![]() |
LeechCraft
0.6.70-10870-g558588d6ec
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 51 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 73 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 105 of file eithercont.h.
Referenced by LeechCraft::Util::DownloadHandler::DownloadHandler().
|
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 86 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 124 of file eithercont.h.
Referenced by LeechCraft::Util::DownloadHandler::DownloadHandler().