diff --git a/fluent/Continuable.h b/fluent/Continuable.h index 8692587..aed0621 100644 --- a/fluent/Continuable.h +++ b/fluent/Continuable.h @@ -39,6 +39,50 @@ namespace detail template class _ContinuableImpl; + /// Corrects void return types from functional types which should be Continuable> + template + struct convert_void_to_continuable; + + template<> + struct convert_void_to_continuable + { + typedef _ContinuableImpl> type; + }; + + template + struct convert_void_to_continuable < _ContinuableImpl<_State, _CTy> > + { + typedef _ContinuableImpl<_State, _CTy> type; + }; + + template + struct unary_chainer; + + // MSVC 12 has issues to detect the parameter pack otherwise. + template + struct unary_chainer< _NextRTy, fu::identity<_NextATy...>> + { + typedef typename convert_void_to_continuable<_NextRTy>::type result_t; + + typedef typename result_t::CallbackFunction callback_t; + + /* + template + static auto chain(_CTy&&) + -> typename convert_void_to_continuable<_NextRTy>::type + // _ContinuableImpl> + { + return typename convert_void_to_continuable<_NextRTy>::type(); + // _ContinuableImpl>(); + } + */ + }; + + template + using unary_chainer_t = unary_chainer< + fu::return_type_of_t::type>, + fu::argument_type_of_t::type>>; + template class _ContinuableImpl, std::function> { @@ -122,50 +166,6 @@ namespace detail return *this; } - /// Corrects void return types from functional types which should be Continuable> - template - struct convert_void_to_continuable; - - template<> - struct convert_void_to_continuable - { - typedef _ContinuableImpl> type; - }; - - template - struct convert_void_to_continuable<_ContinuableImpl<_State, _CTy>> - { - typedef _ContinuableImpl<_State, _CTy> type; - }; - - template - struct unary_chainer; - - // MSVC 12 has issues to detect the parameter pack otherwise. - template - struct unary_chainer<_NextRTy, fu::identity<_NextATy...>> - { - typedef typename convert_void_to_continuable<_NextRTy>::type result_t; - - typedef typename result_t::CallbackFunction callback_t; - - /* - template - static auto chain(_CTy&&) - -> typename convert_void_to_continuable<_NextRTy>::type - // _ContinuableImpl> - { - return typename convert_void_to_continuable<_NextRTy>::type(); - // _ContinuableImpl>(); - } - */ - }; - - template - using unary_chainer_t = unary_chainer< - fu::return_type_of_t::type>, - fu::argument_type_of_t::type>>; - template auto then(_CTy&& functional) -> typename unary_chainer_t<_CTy>::result_t