mirror of
https://github.com/Naios/continuable.git
synced 2026-02-09 11:16:40 +08:00
First Step: Make use of lambda move capture.
This commit is contained in:
parent
614af195cb
commit
f85b495ae2
@ -172,21 +172,17 @@ public:
|
|||||||
typename detail::unary_chainer_t<_CTy, _ATy...>::arguments_t>::value,
|
typename detail::unary_chainer_t<_CTy, _ATy...>::arguments_t>::value,
|
||||||
"Given function signature isn't correct, for now it must match strictly!");
|
"Given function signature isn't correct, for now it must match strictly!");
|
||||||
|
|
||||||
// Transfer the insert function to the local scope.
|
|
||||||
// Also use it as an r-value reference to try to get move semantics with c++11 lambdas.
|
|
||||||
ForwardFunction&& callback = std::move(_callback_insert);
|
|
||||||
|
|
||||||
auto&& corrected = detail::functional_traits<_ATy...>::
|
|
||||||
correct(std::forward<_CTy>(functional));
|
|
||||||
|
|
||||||
return typename detail::unary_chainer_t<_CTy, _ATy...>::continuable_t(
|
return typename detail::unary_chainer_t<_CTy, _ATy...>::continuable_t(
|
||||||
[corrected, callback](typename detail::unary_chainer_t<_CTy, _ATy...>::callback_t&& call_next)
|
[
|
||||||
|
corrected = detail::functional_traits<_ATy...>::correct(std::forward<_CTy>(functional)),
|
||||||
|
callback = std::move(_callback_insert)
|
||||||
|
]
|
||||||
|
(typename detail::unary_chainer_t<_CTy, _ATy...>::callback_t&& call_next) mutable
|
||||||
{
|
{
|
||||||
callback([corrected, call_next](_ATy&&... args) mutable
|
callback([corrected = std::move(corrected), call_next](_ATy&&... args) mutable
|
||||||
{
|
{
|
||||||
// Invoke the next callback
|
// Invoke the next callback
|
||||||
corrected(std::forward<_ATy>(args)...)
|
corrected(std::forward<_ATy>(args)...).invoke(std::move(call_next));
|
||||||
.invoke(std::move(call_next));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}, std::move(*this));
|
}, std::move(*this));
|
||||||
|
|||||||
12
test.cpp
12
test.cpp
@ -638,19 +638,9 @@ int main(int /*argc*/, char** /*argv*/)
|
|||||||
})
|
})
|
||||||
.then([]
|
.then([]
|
||||||
{
|
{
|
||||||
|
return Log("ok, now its really finished!").then(CastSpellPromise(2));
|
||||||
});
|
});
|
||||||
|
|
||||||
std::function<void()> callable = []
|
|
||||||
{
|
|
||||||
std::cout << "ok" << std::endl;
|
|
||||||
};
|
|
||||||
|
|
||||||
auto conv_test_1 = std::bind(callable);
|
|
||||||
|
|
||||||
conv_test_1(1, 1);
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
continuable_returner<std::unique_ptr<int>> test26151_start(std::unique_ptr<int>(new int(5)));
|
continuable_returner<std::unique_ptr<int>> test26151_start(std::unique_ptr<int>(new int(5)));
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user