diff --git a/include/Callback.h b/include/Callback.h index 620d7be..b85fbad 100644 --- a/include/Callback.h +++ b/include/Callback.h @@ -19,6 +19,16 @@ #ifndef _CALLBACK_H_ #define _CALLBACK_H_ +enum SpellCastResult +{ + SPELL_FAILED_SUCCESS = 0, + SPELL_FAILED_AFFECTING_COMBAT = 1, + SPELL_FAILED_ALREADY_AT_FULL_HEALTH = 2, + SPELL_FAILED_ALREADY_AT_FULL_MANA = 3, + SPELL_FAILED_ALREADY_AT_FULL_POWER = 4, + SPELL_FAILED_ALREADY_BEING_TAMED = 5 +}; + #include #include #include diff --git a/include/Continuable.h b/include/Continuable.h index 4364c0d..31a832e 100644 --- a/include/Continuable.h +++ b/include/Continuable.h @@ -189,9 +189,26 @@ public: /// Placeholder template auto all(_CTy&&... functionals) - -> Continuable& + -> Continuable + /*typename detail::multiple_when_all_chainer_t< + fu::identity<_ATy...>, + fu::identity<_CTy...> + >::make_result::continuable_t + */ { - return *this; + return then([]() + { + return Continuable(); + }); + + /* + + return then( + detail::multiple_when_all_chainer_t< + fu::identity<_ATy...>, + fu::identity<_CTy...> + >::make_when_all(std::forward<_CTy>(functionals)...)) + */ } /// Placeholder @@ -491,9 +508,20 @@ namespace detail template struct multiple_when_all_chainer_t_make_result> { - typedef Continuable type; + typedef Continuable continuable_t; - // type create() + typedef std::function return_t; + + template + static return_t create(_CTy&&... functionals) + { + return [=](_ATy&&... args) + { + + + return continuable_t(); + }; + } }; template @@ -507,11 +535,13 @@ namespace detail static std::size_t const size = result_maker::size; + typedef typename multiple_when_all_chainer_t_make_result make_result; + // Creates one continuable from multiple ones static auto make_when_all(_CTy&&... args) - -> typename multiple_when_all_chainer_t_make_result::type + -> typename make_result::return_t { - return multiple_when_all_chainer_t_make_result::type(); + return make_result::create(std::forward<_CTy>(args)...); } }; } diff --git a/test.cpp b/test.cpp index c03e0d2..ae673ad 100644 --- a/test.cpp +++ b/test.cpp @@ -12,15 +12,7 @@ #include -enum SpellCastResult -{ - SPELL_FAILED_SUCCESS = 0, - SPELL_FAILED_AFFECTING_COMBAT = 1, - SPELL_FAILED_ALREADY_AT_FULL_HEALTH = 2, - SPELL_FAILED_ALREADY_AT_FULL_MANA = 3, - SPELL_FAILED_ALREADY_AT_FULL_POWER = 4, - SPELL_FAILED_ALREADY_BEING_TAMED = 5 -}; + template using Optional = boost::optional; @@ -135,6 +127,7 @@ inline auto apply(F && f, T && t) int main(int /*argc*/, char** /*argv*/) { + /* CastSpellPromise(1) .then([](SpellCastResult) { @@ -183,7 +176,7 @@ int main(int /*argc*/, char** /*argv*/) { std::cout << "Finished" << std::endl; }); - + */ //Continuable cb = make_continuable([](Callback&& callback) //{ @@ -345,21 +338,23 @@ int main(int /*argc*/, char** /*argv*/) > >::result_maker::partial_results_t myres123345; + /* auto firstType = detail::multiple_when_all_chainer_t< fu::identity<>, fu::identity< + std::function()>, std::function()>, - std::function()>, std::function()> > >::make_when_all( [] { - return make_continuable(); + // void + return CastSpellPromise(10); }, [] { - return CastSpellPromise(10); + return make_continuable(); }, [] { @@ -368,7 +363,24 @@ int main(int /*argc*/, char** /*argv*/) .then([](SpellCastResult, SpellCastResult) { + }) + .then([] + { + }); + */ + + auto promise = std::move(make_continuable() + .all( + [] + { + // void + return CastSpellPromise(10); + }, + [] + { + return CastSpellPromise(20); + })); std::cout << "ok" << std::endl; return 0;