From 6ce6e0faa768c4796f16dcfe13fce7e470f7b00d Mon Sep 17 00:00:00 2001 From: Naios Date: Wed, 10 Jun 2015 18:48:07 +0200 Subject: [PATCH] more work --- fluent++/Continuable.h | 22 +++++++++++++++------- fluent++/WeakCallbackContainer.h | 2 +- test.cpp | 14 ++++++++------ 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/fluent++/Continuable.h b/fluent++/Continuable.h index 76e8bf9..99ab6b6 100644 --- a/fluent++/Continuable.h +++ b/fluent++/Continuable.h @@ -27,7 +27,15 @@ struct Continuable; template struct Continuable> { + // Function which expects a callback that is inserted from the Continuable + // to chain everything together + std::function)> _callback_insert; + public: + Continuable>() { } + Continuable>(std::function)>&& callback_insert) + : _callback_insert(std::forward)>>(callback_insert)) { } + template Continuable>& then(_CTy&& callback) { @@ -37,16 +45,16 @@ public: namespace detail { - template + template struct ContinuableFactory; - template - struct ContinuableFactory<_FTy, _RTy, ::fu::identity<_ATy>> + template + struct ContinuableFactory<_FTy, _RTy, ::fu::identity>> { static auto CreateFrom(_FTy&& functional) - -> _FTy// Continuable<_ATy> + -> Continuable> { - return _FTy; // Continuable<_ATy>(); + return Continuable>(std::forward<_FTy>(functional)); } }; @@ -58,9 +66,9 @@ namespace detail template inline auto make_continuable(_FTy&& functional) - -> int// decltype(typename detail::continuable_factory_t<_FTy>::CreateFrom(std::declval<_FTy>())) + -> decltype(typename detail::continuable_factory_t<_FTy>::CreateFrom(std::declval<_FTy>())) { - return 1; // detail::continuable_factory_t<_FTy>::CreateFrom(std::forward<_FTy>(functional)); + return detail::continuable_factory_t<_FTy>::CreateFrom(std::forward<_FTy>(functional)); } #endif /// _CONTINUABLE_H_ diff --git a/fluent++/WeakCallbackContainer.h b/fluent++/WeakCallbackContainer.h index 1066dfb..b68e997 100644 --- a/fluent++/WeakCallbackContainer.h +++ b/fluent++/WeakCallbackContainer.h @@ -65,7 +65,7 @@ class WeakCallbackContainer public: WeakCallbackContainer() - : self_reference(this, [](decltype(this) me) { }), handle(0L) { } + : self_reference(this, [](decltype(this)) { }), handle(0L) { } ~WeakCallbackContainer() = default; diff --git a/test.cpp b/test.cpp index a47e91d..1f9e806 100644 --- a/test.cpp +++ b/test.cpp @@ -188,14 +188,16 @@ int main(int argc, char** argv) }) .then([](SpellCastResult result) { - // Wraps a callback function into a continuable - return make_continuable([=](Callback callback) - { - - - }); }); + // Wraps a callback function into a continuable + auto cba1 = make_continuable([=](Callback callback) + { + + + + }); + return 0; }