From b85fe24a66b254a93f28c65aad6e473bd296a127 Mon Sep 17 00:00:00 2001 From: Denis Blank Date: Mon, 22 Jun 2015 15:43:42 +0200 Subject: [PATCH] cleanup --- include/Continuable.h | 65 ++++++++++++++----------------------------- 1 file changed, 21 insertions(+), 44 deletions(-) diff --git a/include/Continuable.h b/include/Continuable.h index 8b4e60a..cffcba9 100644 --- a/include/Continuable.h +++ b/include/Continuable.h @@ -21,35 +21,12 @@ #include "Callback.h" -// Debug includes -#include -#include -#include -template -void log_type(T t, std::string const& msg = "") -{ - std::cout << msg << ": " << typeid(t).name() << std::endl; -} -void debug(std::string const& m) -{ - std::cout << m << std::endl; -} -/// Debug end - template class Continuable; namespace detail { - // unary_chainer forward declaration. - template - struct unary_chainer; - - // creates an empty callback. - template - struct create_empty_callback; - - // trait to identify continuable types + /// Trait to identify continuable types template struct is_continuable : public std::false_type { }; @@ -58,11 +35,9 @@ namespace detail struct is_continuable> : public std::true_type { }; - template - struct multiple_all_chainer - { - - }; + /// Creates an empty callback. + template + struct create_empty_callback; template struct create_empty_callback&&)>> @@ -76,6 +51,7 @@ namespace detail } }; + /// Functional traits forward declaration. template struct functional_traits; @@ -94,7 +70,7 @@ public: typedef Callback<_ATy...> CallbackFunction; typedef std::function&&)> ForwardFunction; -// private: +private: /// Functional which expects a callback that is inserted from the Continuable /// to chain everything together ForwardFunction _callback_insert; @@ -114,6 +90,21 @@ public: } } + /// Helper trait for unary chains like `Continuable::then` + template + struct unary_chainer_t + { + // Corrected user given functional + typedef decltype(detail::functional_traits<_ATy...>:: + correct(std::declval::type>())) corrected_t; + + typedef fu::return_type_of_t continuable_t; + + typedef fu::argument_type_of_t arguments_t; + + typedef typename continuable_t::CallbackFunction callback_t; + }; + public: /// Deleted copy construct Continuable(Continuable const&) = delete; @@ -164,20 +155,6 @@ public: return *this; } - template - struct unary_chainer_t - { - // Corrected user given functional - typedef decltype(detail::functional_traits<_ATy...>:: - correct(std::declval::type>())) corrected_t; - - typedef fu::return_type_of_t continuable_t; - - typedef fu::argument_type_of_t arguments_t; - - typedef typename continuable_t::CallbackFunction callback_t; - }; - /// Waits for this continuable and invokes the given callback. template auto then(_CTy&& functional)