mirror of
https://github.com/Naios/continuable.git
synced 2025-12-07 17:26:47 +08:00
more work
This commit is contained in:
parent
593421c083
commit
6ce6e0faa7
@ -27,7 +27,15 @@ struct Continuable;
|
||||
template <typename... _ATy>
|
||||
struct Continuable<Callback<_ATy...>>
|
||||
{
|
||||
// Function which expects a callback that is inserted from the Continuable
|
||||
// to chain everything together
|
||||
std::function<void(Callback<_ATy...>)> _callback_insert;
|
||||
|
||||
public:
|
||||
Continuable<Callback<_ATy...>>() { }
|
||||
Continuable<Callback<_ATy...>>(std::function<void(Callback<_ATy...>)>&& callback_insert)
|
||||
: _callback_insert(std::forward<std::function<void(Callback<_ATy...>)>>(callback_insert)) { }
|
||||
|
||||
template <typename _CTy>
|
||||
Continuable<Callback<_ATy...>>& then(_CTy&& callback)
|
||||
{
|
||||
@ -37,16 +45,16 @@ public:
|
||||
|
||||
namespace detail
|
||||
{
|
||||
template <typename _FTy, typename _RTy, typename _ATy>
|
||||
template <typename _FTy, typename _RTy, typename... _ATy>
|
||||
struct ContinuableFactory;
|
||||
|
||||
template <typename _FTy, typename _RTy, typename _ATy>
|
||||
struct ContinuableFactory<_FTy, _RTy, ::fu::identity<_ATy>>
|
||||
template <typename _FTy, typename _RTy, typename... _ATy>
|
||||
struct ContinuableFactory<_FTy, _RTy, ::fu::identity<Callback<_ATy...>>>
|
||||
{
|
||||
static auto CreateFrom(_FTy&& functional)
|
||||
-> _FTy// Continuable<_ATy>
|
||||
-> Continuable<Callback<_ATy...>>
|
||||
{
|
||||
return _FTy; // Continuable<_ATy>();
|
||||
return Continuable<Callback<_ATy...>>(std::forward<_FTy>(functional));
|
||||
}
|
||||
};
|
||||
|
||||
@ -58,9 +66,9 @@ namespace detail
|
||||
|
||||
template <typename _FTy>
|
||||
inline auto make_continuable(_FTy&& functional)
|
||||
-> int// decltype(typename detail::continuable_factory_t<_FTy>::CreateFrom(std::declval<_FTy>()))
|
||||
-> decltype(typename detail::continuable_factory_t<_FTy>::CreateFrom(std::declval<_FTy>()))
|
||||
{
|
||||
return 1; // detail::continuable_factory_t<_FTy>::CreateFrom(std::forward<_FTy>(functional));
|
||||
return detail::continuable_factory_t<_FTy>::CreateFrom(std::forward<_FTy>(functional));
|
||||
}
|
||||
|
||||
#endif /// _CONTINUABLE_H_
|
||||
|
||||
@ -65,7 +65,7 @@ class WeakCallbackContainer
|
||||
|
||||
public:
|
||||
WeakCallbackContainer()
|
||||
: self_reference(this, [](decltype(this) me) { }), handle(0L) { }
|
||||
: self_reference(this, [](decltype(this)) { }), handle(0L) { }
|
||||
|
||||
~WeakCallbackContainer() = default;
|
||||
|
||||
|
||||
14
test.cpp
14
test.cpp
@ -188,14 +188,16 @@ int main(int argc, char** argv)
|
||||
})
|
||||
.then([](SpellCastResult result)
|
||||
{
|
||||
// Wraps a callback function into a continuable
|
||||
return make_continuable([=](Callback<SpellCastResult> callback)
|
||||
{
|
||||
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
// Wraps a callback function into a continuable
|
||||
auto cba1 = make_continuable([=](Callback<SpellCastResult> callback)
|
||||
{
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user