From 44e96ac52b72fda65f2f96cd007dea851f523d52 Mon Sep 17 00:00:00 2001 From: Denis Blank Date: Wed, 1 Jul 2015 22:27:31 +0200 Subject: [PATCH] correct a forward call --- include/Continuable.h | 2 +- test.cpp | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/include/Continuable.h b/include/Continuable.h index 7bf9c38..61d974f 100644 --- a/include/Continuable.h +++ b/include/Continuable.h @@ -328,7 +328,7 @@ namespace detail template static std::function(_ATy...)> wrap(_CTy&& functional) { - return [functional](_ATy... args) + return [functional](_ATy&&... args) { // Invoke the original callback functional(std::forward<_ATy>(args)...); diff --git a/test.cpp b/test.cpp index 89e9344..559315a 100644 --- a/test.cpp +++ b/test.cpp @@ -72,6 +72,22 @@ Continuable Validate() }); } +Continuable&&> MoveTest() +{ + return make_continuable([=](Callback&&>&& callback) + { + // Move the unique ptr out to test moveability + std::unique_ptr ptr(new int(5)); + callback(std::move(ptr)); + }); +} + +void testMoveAbleNormal(std::function&&)> callback) +{ + std::unique_ptr ptr(new int(5)); + callback(std::move(ptr)); +} + template void test_unwrap(std::string const& msg) { @@ -99,6 +115,15 @@ int main(int /*argc*/, char** /*argv*/) return Validate(); }); + MoveTest() + .then([](std::unique_ptr&& ptr) + { + static_assert(std::is_rvalue_reference::value, "no rvalue"); + + // Error here + std::unique_ptr other = std::move(ptr); + }); + // Mockup of aggregate methods make_continuable() .all(