From b747d439d8708064dabd11b344e3990fe1d9d5ae Mon Sep 17 00:00:00 2001 From: Naios Date: Mon, 15 Jun 2015 02:06:46 +0200 Subject: [PATCH] more work --- fluent/Continuable.h | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/fluent/Continuable.h b/fluent/Continuable.h index d6b679d..64f79e3 100644 --- a/fluent/Continuable.h +++ b/fluent/Continuable.h @@ -47,12 +47,28 @@ namespace detail struct convert_void_to_continuable { typedef _ContinuableImpl> type; + + template + static type InvokeAndReturn(std::function const& functional, std::forward... args) + { + functional(std::forward(args)...); + return type(); /*[](Callback<>&& callback) + { + callback(); + });*/ + } }; template struct convert_void_to_continuable<_ContinuableImpl<_State, _CTy>> { typedef _ContinuableImpl<_State, _CTy> type; + + template + static type InvokeAndReturn(std::function const& functional, std::forward... args) + { + return functional(std::forward(args)...); + } }; template @@ -156,6 +172,8 @@ namespace detail return *this; } + + template auto then(_CTy&& functional) -> typename unary_chainer_t<_CTy>::result_t @@ -165,15 +183,17 @@ namespace detail // next(unary_chainer_t<_CTy>::callback_t()); return typename unary_chainer_t<_CTy>::result_t - (std::move(*this), [=](typename unary_chainer_t<_CTy>::callback_t&& /*next_insert_callback*/) + (std::move(*this), [=](typename unary_chainer_t<_CTy>::callback_t&& next_insert_callback) { _callback_insert([=](_ATy... args) { - // typename unary_chainer_t<_CTy>::result_t next = + typename unary_chainer_t<_CTy>::result_t next = functional(std::forward<_ATy>(args)...); // next_insert_callback(result.); // next._insert_callback(next_insert_callback); + + // FIXME Call next callback }); }); }