correct a forward call

This commit is contained in:
Denis Blank 2015-07-01 22:27:31 +02:00 committed by Naios
parent 01d38964a7
commit 44e96ac52b
2 changed files with 26 additions and 1 deletions

View File

@ -328,7 +328,7 @@ namespace detail
template<typename _CTy> template<typename _CTy>
static std::function<Continuable<>(_ATy...)> wrap(_CTy&& functional) static std::function<Continuable<>(_ATy...)> wrap(_CTy&& functional)
{ {
return [functional](_ATy... args) return [functional](_ATy&&... args)
{ {
// Invoke the original callback // Invoke the original callback
functional(std::forward<_ATy>(args)...); functional(std::forward<_ATy>(args)...);

View File

@ -72,6 +72,22 @@ Continuable<bool> Validate()
}); });
} }
Continuable<std::unique_ptr<int>&&> MoveTest()
{
return make_continuable([=](Callback<std::unique_ptr<int>&&>&& callback)
{
// Move the unique ptr out to test moveability
std::unique_ptr<int> ptr(new int(5));
callback(std::move(ptr));
});
}
void testMoveAbleNormal(std::function<void(std::unique_ptr<int>&&)> callback)
{
std::unique_ptr<int> ptr(new int(5));
callback(std::move(ptr));
}
template <typename... T> template <typename... T>
void test_unwrap(std::string const& msg) void test_unwrap(std::string const& msg)
{ {
@ -99,6 +115,15 @@ int main(int /*argc*/, char** /*argv*/)
return Validate(); return Validate();
}); });
MoveTest()
.then([](std::unique_ptr<int>&& ptr)
{
static_assert(std::is_rvalue_reference<decltype(ptr)>::value, "no rvalue");
// Error here
std::unique_ptr<int> other = std::move(ptr);
});
// Mockup of aggregate methods // Mockup of aggregate methods
make_continuable() make_continuable()
.all( .all(