From 06df1c43132f688127fd36456de1aa5908aad9ac Mon Sep 17 00:00:00 2001 From: Naios Date: Wed, 10 Jun 2015 16:24:20 +0200 Subject: [PATCH] some changes --- fluent++/Callback.h | 3 +++ fluent++/Continuable.h | 19 ++++++++++++++++--- test.cpp | 26 ++++++++++++++++++++------ 3 files changed, 39 insertions(+), 9 deletions(-) diff --git a/fluent++/Callback.h b/fluent++/Callback.h index 20c7562..b9bba05 100644 --- a/fluent++/Callback.h +++ b/fluent++/Callback.h @@ -80,6 +80,7 @@ using shared_callback_of_t = typename detail::unwrap_callback<_CTy>::SharedCallb template using weak_callback_of_t = typename detail::unwrap_callback<_CTy>::WeakCallbackType; + template inline shared_callback_of_t<_CTy> make_shared_callback(_CTy&& callback) @@ -88,6 +89,7 @@ inline shared_callback_of_t<_CTy> (std::forward>(callback)); } +/* Disabled due to clang errors template inline auto make_weak_wrapped_callback(WeakCallback const& weak_callback) -> Callback @@ -103,5 +105,6 @@ inline auto make_weak_wrapped_callback(SharedCallback const& shared_cal // Some workarounds for clang... return detail::WeakProxyFactory::CreateProxyFromShared(shared_callback); } +*/ #endif /// _CALLBACK_H_ diff --git a/fluent++/Continuable.h b/fluent++/Continuable.h index a66af42..39576c9 100644 --- a/fluent++/Continuable.h +++ b/fluent++/Continuable.h @@ -20,25 +20,38 @@ #include "Callback.h" + + template class ContinuableBase { }; -template +template class Continuable; template class Continuable, void> { - +public: + typedef bool type; }; template class Continuable, _WTy> { - static_assert(false, ""); +public: + typedef int type; }; + +/* +template +auto make_continuable(_CTy&& callback) + -> +{ +} +*/ + #endif /// _CONTINUABLE_H_ diff --git a/test.cpp b/test.cpp index 72a4af3..f338a6c 100644 --- a/test.cpp +++ b/test.cpp @@ -8,6 +8,16 @@ #include #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 +}; + ProtoContinueable CastSpell(int id) { std::cout << "Cast " << id << std::endl; @@ -24,12 +34,12 @@ ProtoContinueable MoveTo(int point) return ProtoContinueable(); } -void CastSpell(int id, Callback const& callback) +void CastSpell(int id, Callback const& callback) { std::cout << "Cast " << id << std::endl; - // on success call true - callback(true); + // on success call the callback with SPELL_FAILED_SUCCESS + callback(SPELL_FAILED_SUCCESS); } void MoveTo(int point, Callback const& callback) @@ -42,9 +52,9 @@ void MoveTo(int point, Callback const& callback) int main(int argc, char** argv) { - make_waterfall>() + make_waterfall>() // .then(std::bind(&CastSpell, 71382, std::placeholders::_1)) - .then([](bool success, Callback const& callback) + .then([](SpellCastResult result, Callback const& callback) { MoveTo(1, callback); }) @@ -141,14 +151,18 @@ int main(int argc, char** argv) std::cout << "huhu" << std::endl; }); + /* auto wrapped = make_weak_wrapped_callback(weak_2); auto wrapped2 = make_weak_wrapped_callback(WeakCallback<>(weak_2)); - wrapped(); wrapped2(); + */ typedef Continuable> cont; + typedef Continuable>::type myty1; + typedef Continuable, float>::type myty2; + return 0; }