fix void returning functions

This commit is contained in:
Denis Blank 2015-06-16 13:19:20 +02:00 committed by Naios
parent 2c479d4c43
commit 5ca400e5d1
2 changed files with 7 additions and 6 deletions

View File

@ -192,7 +192,7 @@ namespace detail
return typename unary_chainer_t<_CTy>::result_t( return typename unary_chainer_t<_CTy>::result_t(
[functional, callback](typename unary_chainer_t<_CTy>::callback_t&& call_next) [functional, callback](typename unary_chainer_t<_CTy>::callback_t&& call_next)
{ {
callback([functional, call_next](_ATy... args) mutable callback([functional, call_next](_ATy&&... args) mutable
{ {
typename unary_chainer_t<_CTy>::result_t continuable = typename unary_chainer_t<_CTy>::result_t continuable =
unary_chainer_t<_CTy>::base::invoke(functional, std::forward<_ATy>(args)...); unary_chainer_t<_CTy>::base::invoke(functional, std::forward<_ATy>(args)...);
@ -228,14 +228,15 @@ namespace detail
typedef _ContinuableImpl<DefaultContinuableState, Callback<>> type; typedef _ContinuableImpl<DefaultContinuableState, Callback<>> type;
template<typename Fn, typename... Args> template<typename Fn, typename... Args>
static type invoke(Fn functional, Args... args) static type invoke(Fn functional, Args&&... args)
{ {
// Invoke the void returning functional // Invoke the void returning functional
functional(std::forward<Args>(args)...); functional(std::forward<Args>(args)...);
// Return a fake void continuable // Return a fake void continuable
return type([](Callback<>&&) return type([](Callback<>&& callback)
{ {
callback();
}); });
} }
}; };
@ -246,7 +247,7 @@ namespace detail
typedef _ContinuableImpl<_State, _CTy> type; typedef _ContinuableImpl<_State, _CTy> type;
template<typename Fn, typename... Args> template<typename Fn, typename... Args>
static type invoke(Fn functional, Args... args) static type invoke(Fn functional, Args&&... args)
{ {
return functional(std::forward<Args>(args)...); return functional(std::forward<Args>(args)...);
} }

View File

@ -56,9 +56,9 @@ int main(int /*argc*/, char** /*argv*/)
}) })
.then([](SpellCastResult) .then([](SpellCastResult)
{ {
return Validate(); std::cout << "Pause a callback (void test) " << std::endl;
}) })
.then([](bool) .then([]
{ {
return CastSpell(3); return CastSpell(3);
}) })