From 9a135add5677a5439da21dd89988eb04b3d6f4a6 Mon Sep 17 00:00:00 2001 From: Denis Blank Date: Sun, 14 Jun 2015 23:54:44 +0200 Subject: [PATCH] some brainstorming... --- test.cpp | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/test.cpp b/test.cpp index 9c9c0c2..b9a3d3b 100644 --- a/test.cpp +++ b/test.cpp @@ -113,6 +113,43 @@ int main(int /*argc*/, char** /*argv*/) typedef fu::requires_functional_constructible>::type test_assert1; // typedef fu::requires_functional_constructible>::type test_assert2; + // Brainstorming: this shows an example callback chain + // Given by continuable + std::function&&)> fn1 = [](Callback&& callback) + { + callback(SPELL_FAILED_AFFECTING_COMBAT); + }; + + // Implemented by user + std::function&&)>(SpellCastResult)> cn1 = [](SpellCastResult) + { + // Given by continuable + return [](Callback&& callback) + { + callback(true); + }; + }; + + // Auto created wrapper by the continuable + std::function wr1 = [&cn1](SpellCastResult result) + { + // Wrapper functional to process unary or multiple promised callbacks + // Returned from the user + std::function&&)> fn2 = cn1(result); + + fn2([](bool val) + { + // Finished + std::cout << "Callback chain finished! -> " << val << std::endl; + }); + }; + + Callback<> entry = [&] + { + fn1(std::move(wr1)); + }; + + entry(); std::cout << "ok" << std::endl; return 0;