From 0789c0ff4a52a80965d4c32098d09d8e57d8cb11 Mon Sep 17 00:00:00 2001 From: Naios Date: Tue, 16 Jun 2015 00:13:16 +0200 Subject: [PATCH] some more work --- fluent/Continuable.h | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/fluent/Continuable.h b/fluent/Continuable.h index c22d2ed..a52dc9a 100644 --- a/fluent/Continuable.h +++ b/fluent/Continuable.h @@ -48,16 +48,17 @@ namespace detail { typedef _ContinuableImpl> type; + template + static type invoke(Fn functional, Args... args) + { + // Invoke the void returning functional + functional(std::forward(args)...); - //template - //static type InvokeAndReturn(std::function const& functional, std::forward... args) - //{ - // functional(std::forward(args)...); - // return type(); /*[](Callback<>&& callback) - // { - // callback(); - // });*/ - //} + // Return a fake void continuable + return type([](Callback<>&&) + { + }); + } }; template @@ -65,11 +66,11 @@ namespace detail { typedef _ContinuableImpl<_State, _CTy> type; - //template - //static type InvokeAndReturn(std::function const& functional, std::forward... args) - //{ - // return functional(std::forward(args)...); - //} + template + static type invoke(Fn functional, Args... args) + { + return functional(std::forward(args)...); + } }; template @@ -79,6 +80,8 @@ namespace detail template struct unary_chainer<_NextRTy, fu::identity<_NextATy...>> { + typedef convert_void_to_continuable<_NextRTy> base; + typedef typename convert_void_to_continuable<_NextRTy>::type result_t; typedef typename result_t::CallbackFunction callback_t; @@ -182,14 +185,14 @@ namespace detail ForwardFunction&& callback = std::move(_callback_insert); return typename unary_chainer_t<_CTy>::result_t( - [functional, callback](typename unary_chainer_t<_CTy>::callback_t&& next) + [functional, callback](unary_chainer_t<_CTy>::callback_t&& call_next) { - callback([functional, next](_ATy... args) + callback([functional, call_next](_ATy&&... args) { - typename unary_chainer_t<_CTy>::result_t continuable; - //= next(std::forward<_ATy>(args)...); + unary_chainer_t<_CTy>::result_t continuable = + unary_chainer_t<_CTy>::base::invoke(functional, std::forward<_ATy>(args)...); - // continuable(); + // continuable._callback_insert(std::move(call_next)); }); }, std::move(*this));