diff --git a/fluent++/fluent++.hpp b/fluent++/fluent++.hpp index 9249e34..c64e4a7 100644 --- a/fluent++/fluent++.hpp +++ b/fluent++/fluent++.hpp @@ -63,8 +63,25 @@ fluent_step make_waterfall() } +struct Continueable +{ + template + Continueable then(Callback&& callback) + { + return Continueable(); + } + template + Continueable weak(Container& container) + { + return Continueable(); + } + Continueable strong() + { + return Continueable(); + } +}; void do_export(); diff --git a/test.cpp b/test.cpp index 9c3e43d..364f759 100644 --- a/test.cpp +++ b/test.cpp @@ -7,6 +7,22 @@ #include #include +Continueable CastSpell(int id) +{ + std::cout << "Cast " << id << std::endl; + + // on success call true + return Continueable(); +} + +Continueable MoveTo(int point) +{ + std::cout << "Move to point " << point << std::endl; + + // on success call true + return Continueable(); +} + void CastSpell(int id, Callback const& callback) { std::cout << "Cast " << id << std::endl; @@ -26,7 +42,7 @@ void MoveTo(int point, Callback const& callback) int main(int argc, char** argv) { make_waterfall>() - .then(std::bind(&CastSpell, 71382, std::placeholders::_1)) + // .then(std::bind(&CastSpell, 71382, std::placeholders::_1)) .then([](bool success, Callback const& callback) { MoveTo(1, callback); @@ -37,6 +53,14 @@ int main(int argc, char** argv) std::cout << "finish everything" << std::endl; }); + + + auto cabt = []() + { + // Do something + return MoveTo(2); + }; + typedef Callback cbd1; typedef WeakCallback cbd2; typedef SharedCallback cbd3; @@ -55,6 +79,24 @@ int main(int argc, char** argv) { WeakCallbackContainer callback; + // Some tests + CastSpell(22872) + .weak(callback) + .then([](bool success) + { + if (success) + { + // do something + } + + // Do something + /*return*/ MoveTo(2); + }) + .then([] + { + + }); + std::shared_ptr dealloc_test(new int{2}, [](int* me) { std::cout << "dealloc ok" << std::endl;