fix some wrong releases

This commit is contained in:
Naios 2015-06-11 17:34:22 +02:00
parent b2050727c4
commit b5c3d7d0a8
2 changed files with 14 additions and 6 deletions

View File

@ -59,11 +59,16 @@ public:
/// Move construct /// Move construct
template <typename _RCTy, typename _RState> template <typename _RCTy, typename _RState>
Continuable(Continuable<_RCTy, _RState>&& right) : released(false) Continuable(Continuable<_RCTy, _RState>&& right) : released(right.released)
{ {
right.released = true; right.released = true;
} }
// Construct through a ForwardFunction
template<typename _FTy>
Continuable(_FTy&& callback_insert)
: _callback_insert(std::forward<_FTy>(callback_insert)), released(false) { }
/// Destructor which calls the dispatch chain if needed. /// Destructor which calls the dispatch chain if needed.
~Continuable() ~Continuable()
{ {
@ -87,13 +92,11 @@ public:
return *this; return *this;
} }
template<typename _FTy> // TODO Accept only correct callbacks
Continuable(_FTy&& callback_insert)
: _callback_insert(std::forward<_FTy>(callback_insert)) { }
template <typename _CTy> template <typename _CTy>
Continuable<Callback<_ATy...>> then(_CTy&&) Continuable<Callback<_ATy...>> then(_CTy&&)
{ {
// TODO Transmute the returned callback here.
return Continuable<Callback<_ATy...>>(std::move(*this)); return Continuable<Callback<_ATy...>>(std::move(*this));
} }
}; };

View File

@ -42,11 +42,14 @@ int main(int /*argc*/, char** /*argv*/)
test_unwrap<std::function<void()>>("std::function<void()>"); test_unwrap<std::function<void()>>("std::function<void()>");
test_unwrap<std::vector<std::string>>("std::vector<std::string>"); test_unwrap<std::vector<std::string>>("std::vector<std::string>");
auto voidcontinue = make_continuable([=](Callback<>&& /*callback*/) make_continuable([=](Callback<>&& /*callback*/)
{ {
}); });
int i = 0;
++i;
auto lam = [=](Callback<SpellCastResult>&& /*callback*/) auto lam = [=](Callback<SpellCastResult>&& /*callback*/)
{ {
// on success call the callback with SPELL_FAILED_SUCCESS // on success call the callback with SPELL_FAILED_SUCCESS
@ -95,6 +98,8 @@ int main(int /*argc*/, char** /*argv*/)
}); });
CastSpell(63362);
std::vector<int> myvec; std::vector<int> myvec;
typedef fu::requires_functional_constructible<std::function<void()>>::type test_assert1; typedef fu::requires_functional_constructible<std::function<void()>>::type test_assert1;