From c82a721b37a64aa173b76e5f63367e920abe0617 Mon Sep 17 00:00:00 2001 From: Denis Blank Date: Thu, 11 Jun 2015 17:34:22 +0200 Subject: [PATCH] fix some wrong releases --- fluent/Continuable.h | 13 ++++++++----- test.cpp | 7 ++++++- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/fluent/Continuable.h b/fluent/Continuable.h index bfc3f03..de78d0b 100644 --- a/fluent/Continuable.h +++ b/fluent/Continuable.h @@ -59,11 +59,16 @@ public: /// Move construct template - Continuable(Continuable<_RCTy, _RState>&& right) : released(false) + Continuable(Continuable<_RCTy, _RState>&& right) : released(right.released) { right.released = true; } + // Construct through a ForwardFunction + template + Continuable(_FTy&& callback_insert) + : _callback_insert(std::forward<_FTy>(callback_insert)), released(false) { } + /// Destructor which calls the dispatch chain if needed. ~Continuable() { @@ -87,13 +92,11 @@ public: return *this; } - template - Continuable(_FTy&& callback_insert) - : _callback_insert(std::forward<_FTy>(callback_insert)) { } - + // TODO Accept only correct callbacks template Continuable> then(_CTy&&) { + // TODO Transmute the returned callback here. return Continuable>(std::move(*this)); } }; diff --git a/test.cpp b/test.cpp index b37c010..9ed71cb 100644 --- a/test.cpp +++ b/test.cpp @@ -42,11 +42,14 @@ int main(int /*argc*/, char** /*argv*/) test_unwrap>("std::function"); test_unwrap>("std::vector"); - auto voidcontinue = make_continuable([=](Callback<>&& /*callback*/) + make_continuable([=](Callback<>&& /*callback*/) { }); + int i = 0; + ++i; + auto lam = [=](Callback&& /*callback*/) { // on success call the callback with SPELL_FAILED_SUCCESS @@ -95,6 +98,8 @@ int main(int /*argc*/, char** /*argv*/) }); + CastSpell(63362); + std::vector myvec; typedef fu::requires_functional_constructible>::type test_assert1;