fix void returning functions

This commit is contained in:
Naios 2015-06-16 13:19:20 +02:00
parent 1c43546bc5
commit 74f3cf603d
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(
[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 =
unary_chainer_t<_CTy>::base::invoke(functional, std::forward<_ATy>(args)...);
@ -228,14 +228,15 @@ namespace detail
typedef _ContinuableImpl<DefaultContinuableState, Callback<>> type;
template<typename Fn, typename... Args>
static type invoke(Fn functional, Args... args)
static type invoke(Fn functional, Args&&... args)
{
// Invoke the void returning functional
functional(std::forward<Args>(args)...);
// Return a fake void continuable
return type([](Callback<>&&)
return type([](Callback<>&& callback)
{
callback();
});
}
};
@ -246,7 +247,7 @@ namespace detail
typedef _ContinuableImpl<_State, _CTy> type;
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)...);
}

View File

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