more work

This commit is contained in:
Denis Blank 2015-06-10 18:48:07 +02:00 committed by Naios
parent 38338dfea5
commit aa48e9bb57
3 changed files with 24 additions and 14 deletions

View File

@ -27,7 +27,15 @@ struct Continuable;
template <typename... _ATy> template <typename... _ATy>
struct Continuable<Callback<_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: 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> template <typename _CTy>
Continuable<Callback<_ATy...>>& then(_CTy&& callback) Continuable<Callback<_ATy...>>& then(_CTy&& callback)
{ {
@ -37,16 +45,16 @@ public:
namespace detail namespace detail
{ {
template <typename _FTy, typename _RTy, typename _ATy> template <typename _FTy, typename _RTy, typename... _ATy>
struct ContinuableFactory; struct ContinuableFactory;
template <typename _FTy, typename _RTy, typename _ATy> template <typename _FTy, typename _RTy, typename... _ATy>
struct ContinuableFactory<_FTy, _RTy, ::fu::identity<_ATy>> struct ContinuableFactory<_FTy, _RTy, ::fu::identity<Callback<_ATy...>>>
{ {
static auto CreateFrom(_FTy&& functional) 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> template <typename _FTy>
inline auto make_continuable(_FTy&& functional) 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_ #endif /// _CONTINUABLE_H_

View File

@ -65,7 +65,7 @@ class WeakCallbackContainer
public: public:
WeakCallbackContainer() WeakCallbackContainer()
: self_reference(this, [](decltype(this) me) { }), handle(0L) { } : self_reference(this, [](decltype(this)) { }), handle(0L) { }
~WeakCallbackContainer() = default; ~WeakCallbackContainer() = default;

View File

@ -188,14 +188,16 @@ int main(int argc, char** argv)
}) })
.then([](SpellCastResult result) .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; return 0;
} }