diff --git a/fluent/Continuable.h b/fluent/Continuable.h index 9235adb..81f81d0 100644 --- a/fluent/Continuable.h +++ b/fluent/Continuable.h @@ -23,31 +23,46 @@ namespace detail { + template + struct ContinuableState; + + template + struct ContinuableState, _Proxy> + { + }; + + typedef ContinuableState, void> EmptyContinuableState; } // detail -template -struct ContinuableState -/* -; -template -struct ContinuableState -*/ -{ -}; - -template > +template class Continuable; -template +template class Continuable, _State> { + /// Corrects void return types from functional types which should be Continuable> + template + struct convert_void_to_continuable; + + template<> + struct convert_void_to_continuable + { + typedef Continuable> type; + }; + + template + struct convert_void_to_continuable> + { + typedef Continuable<_CArgs...> type; + }; + public: typedef std::function&&)> ForwardFunction; private: - // Functional which expects a callback that is inserted from the Continuable - // to chain everything together + /// Functional which expects a callback that is inserted from the Continuable + /// to chain everything together ForwardFunction _callback_insert; bool _released; @@ -58,11 +73,11 @@ private: public: /// Deleted copy construct - template + template Continuable(Continuable<_RCTy, _RState> const&) = delete; /// Move construct - template + template Continuable(Continuable<_RCTy, _RState>&& right) : _released(right._released) { @@ -85,11 +100,11 @@ public: } /// Deleted copy assign - template + template Continuable& operator= (Continuable<_RCTy, _RState> const&) = delete; /// Move construct assign - template + template Continuable& operator= (Continuable<_RCTy, _RState>&& right) { _released = right._released; @@ -98,13 +113,23 @@ public: } // TODO Accept only correct callbacks - template + template Continuable> then(_CTy&&) { // TODO Transmute the returned callback here. return Continuable>(std::move(*this)); } + /* + // TODO Accept only correct callbacks + template + Continuable> all(_CTy&&...) + { + // TODO Transmute the returned callback here. + return Continuable>(std::move(*this)); + } + */ + /// Invalidates the Continuable Continuable& invalidate() { @@ -115,10 +140,10 @@ public: namespace detail { - template + template struct ContinuableFactory; - template + template struct ContinuableFactory<_FTy, _RTy, ::fu::identity&&>> { static auto CreateFrom(_FTy&& functional) @@ -129,7 +154,7 @@ namespace detail } }; - template + template using continuable_factory_t = ContinuableFactory< _FTy, ::fu::return_type_of_t<_FTy>, ::fu::argument_type_of_t<_FTy>>; @@ -143,7 +168,7 @@ namespace detail /// /* Continue here */ /// callback(5); /// }); -template +template inline auto make_continuable(_FTy&& functional) -> decltype(detail::continuable_factory_t<_FTy>::CreateFrom(std::declval<_FTy>())) { diff --git a/fluent/fluent++.hpp b/fluent/fluent++.hpp index e941e55..34dc634 100644 --- a/fluent/fluent++.hpp +++ b/fluent/fluent++.hpp @@ -11,13 +11,13 @@ /* struct ProtoContinueable { - template + template ProtoContinueable then(Callback&& callback) { return ProtoContinueable(); } - template + template ProtoContinueable weak(Container& container) { return ProtoContinueable();