diff --git a/test.cpp b/test.cpp index 07baf33..7a547a2 100644 --- a/test.cpp +++ b/test.cpp @@ -115,13 +115,13 @@ int main(int /*argc*/, char** /*argv*/) // Brainstorming: this shows an example callback chain // Given by continuable - std::function&&)> fn1 = [](Callback&& callback) + std::function&&)> continuable_1 = [](Callback&& callback) { callback(SPELL_FAILED_AFFECTING_COMBAT); }; // Implemented by user - std::function&&)>(SpellCastResult)> cn1 = [](SpellCastResult) + std::function&&)>(SpellCastResult)> callback_by_user_1 = [](SpellCastResult) { // Given by continuable // Fn2 @@ -144,26 +144,20 @@ int main(int /*argc*/, char** /*argv*/) }; }; - // Auto created wrapper by the continuable - std::function wr1 = [&](SpellCastResult result) + // Entry point + std::function&&>)> entry = [continuable_1 /*= move*/, callback_by_user_1 /*given by the user (::then(...))*/] + (std::function&&)>) { - // Wrapper functional to process unary or multiple promised callbacks - // Returned from the user - std::function&&)> fn2 = cn1(result); - - // Auto wrapper - fn2([&](bool value) + // Call with auto created wrapper by the continuable + continuable_1([&](SpellCastResult result /*forward args*/) { - cn2(value); + // Wrapper functional to process unary or multiple promised callbacks + // Returned from the user + std::function&&)> fn2 = callback_by_user_1(/*forward args*/ result); + return std::move(fn2); }); }; - - // Call this to start the chain - Callback<> entry = [&] - { - fn1(std::move(wr1)); - }; - + // Here we go entry();