LeechCraft 0.6.70-16373-g319c272718
Modular cross-platform feature rich live environment.
Loading...
Searching...
No Matches
eithercont.h
Go to the documentation of this file.
1/**********************************************************************
2 * LeechCraft - modular cross-platform feature rich internet client.
3 * Copyright (C) 2006-2014 Georg Rudoy
4 *
5 * Distributed under the Boost Software License, Version 1.0.
6 * (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7 **********************************************************************/
8
9#pragma once
10
11#include <functional>
12
13namespace LC
14{
15namespace Util
16{
29 template<typename LeftSig, typename RightSig>
31 {
32 using Left_f = std::function<LeftSig>;
33 using Right_f = std::function<RightSig>;
34 Left_f Left_;
35 Right_f Right_;
36 public:
40 EitherCont () = default;
41
51 template<typename L, typename R>
52 EitherCont (const L& l, const R& r)
53 : Left_ { l }
54 , Right_ { r }
55 {
56 }
57
65 explicit operator bool () const
66 {
67 return Left_ && Right_;
68 }
69
83 template<typename... Args>
84 auto Left (Args&&... args) const
85 {
86 return Left_ (std::forward<Args> (args)...);
87 }
88
102 template<typename... Args>
103 auto Right (Args&&... args) const
104 {
105 return Right_ (std::forward<Args> (args)...);
106 }
107 };
108}
109}
A peir of two functions, typically a continuation and an error handler.
Definition eithercont.h:31
auto Right(Args &&... args) const
Invoke the right function and return its result.
Definition eithercont.h:103
auto Left(Args &&... args) const
Invoke the left function and return its result.
Definition eithercont.h:84
EitherCont()=default
Default-constructs the continuation with uninitialized functions.
EitherCont(const L &l, const R &r)
Sets the left and right functions to l and r.
Definition eithercont.h:52
Container< T > Filter(const Container< T > &c, F f)
Definition prelude.h:118
Definition constants.h:15