From 6fedd81df1a6fe3277e09a5d85758efb68e67eef Mon Sep 17 00:00:00 2001 From: Denis Blank Date: Thu, 2 Jul 2015 16:16:46 +0200 Subject: [PATCH] Calculate the offset --- include/Continuable.h | 26 +++++++++++++++++++++++++- test.cpp | 19 +++++++++++++++---- 2 files changed, 40 insertions(+), 5 deletions(-) diff --git a/include/Continuable.h b/include/Continuable.h index 1139fe5..9bfb829 100644 --- a/include/Continuable.h +++ b/include/Continuable.h @@ -19,6 +19,9 @@ #ifndef _CONTINUABLE_H_ #define _CONTINUABLE_H_ +#include +#include + #include "Callback.h" template @@ -456,7 +459,12 @@ namespace detail template struct multiple_result_maker : multiple_result_maker< - Position + 1, + Position + + std::tuple_size< + typename identity_to_tuple< + typename unary_chainer_t::callback_arguments_t + >::type + >::value, typename concat_identities< Args, typename unary_chainer_t::callback_arguments_t @@ -490,6 +498,16 @@ namespace detail typedef std::function return_t; + struct ResultStorage + { + ResultStorage(std::size_t count_) + : count(count_) { } + + std::size_t count; + + std::tuple result; + }; + template static return_t create(_CTy&&... functionals) { @@ -498,9 +516,15 @@ namespace detail // Fake continuable which wraps all continuables together return make_continuable([](Callback&& callback) { + std::shared_ptr result( + new ResultStorage(sizeof...(_CTy))); + // auto shared = std::make_shared(ResultStorage()); + int i = 0; + ++i; + std::cout << "hey all was called!" << std::endl; }); }; } diff --git a/test.cpp b/test.cpp index 5de4409..525669a 100644 --- a/test.cpp +++ b/test.cpp @@ -152,6 +152,7 @@ inline auto apply(F && f, T && t) int main(int /*argc*/, char** /*argv*/) { + /* CastSpellPromise(1) .then([](SpellCastResult) { @@ -210,7 +211,7 @@ int main(int /*argc*/, char** /*argv*/) { std::cout << "Finished" << std::endl; }); - + */ //Continuable cb = make_continuable([](Callback&& callback) //{ @@ -331,7 +332,8 @@ int main(int /*argc*/, char** /*argv*/) decltype(CastSpellPromise(2)), decltype(TrivialPromise()), std::function()>, - std::function()> + std::function()>, + std::function()> > maker; @@ -406,7 +408,7 @@ int main(int /*argc*/, char** /*argv*/) }); */ - auto promise = make_continuable() + make_continuable() .all( [] { return CastSpellPromise(10) @@ -414,8 +416,17 @@ int main(int /*argc*/, char** /*argv*/) }, [] { return CastSpellPromise(20); + }, + [] { + return make_continuable([](Callback&& callback) + { + callback(true, false); + }); + }, + [] { + return CastSpellPromise(25); }) - .then([](SpellCastResult, SpellCastResult) + .then([](SpellCastResult, SpellCastResult, bool, bool, SpellCastResult) { })