diff options
Diffstat (limited to 'lib/fwdlib.hpp')
| -rw-r--r-- | lib/fwdlib.hpp | 19 | 
1 files changed, 11 insertions, 8 deletions
| diff --git a/lib/fwdlib.hpp b/lib/fwdlib.hpp index 623dc13..51450c1 100644 --- a/lib/fwdlib.hpp +++ b/lib/fwdlib.hpp @@ -10,7 +10,9 @@  using namespace std; -static void fwd_getline(auto next) +typedef const char *fwd_err_t; + +static fwd_err_t fwd_getline(auto next)  {  	if (cin.eof())  		return next(optional<string>{}); @@ -21,13 +23,13 @@ static void fwd_getline(auto next)  		return next(optional<string>{});  } -static void fwd_foreach(auto container, auto next) +static fwd_err_t fwd_foreach(auto container, auto next)  {  	for (auto &n : container)  		next(n);  } -static void fwd_some(auto option, auto ok, auto fail) +static fwd_err_t fwd_some(auto option, auto ok, auto fail)  {  	if (option)  		return ok(std::move(option.value())); @@ -35,12 +37,12 @@ static void fwd_some(auto option, auto ok, auto fail)  		return fail();  } -static void fwd_copy(auto n, auto next) +static fwd_err_t fwd_copy(auto n, auto next)  {  	return next(n, n);  } -static void fwd_null(auto *x, auto fail, auto ok) +static fwd_err_t fwd_null(auto *x, auto fail, auto ok)  {  	if (x)  		return ok(*x); @@ -48,18 +50,19 @@ static void fwd_null(auto *x, auto fail, auto ok)  		return fail();  } -static void fwd_insert(auto container, auto elem, auto next) +static fwd_err_t fwd_insert(auto container, auto elem, auto next)  {  	container.insert(std::move(elem));  	return next(std::move(container));  } -static void fwd_println(auto elem) +static fwd_err_t fwd_println(auto elem)  {  	cout << elem << endl; +	return nullptr;  } -static void fwd_intalloc(auto ok) +static fwd_err_t fwd_intalloc(auto ok)  {  	int *p = new int{20};  	ok(p); | 
