disallow move assign of continuables

This commit is contained in:
Denis Blank 2015-08-11 20:35:18 +02:00
parent f70efcfc01
commit 5e5273fae7
2 changed files with 19 additions and 27 deletions

View File

@ -40,22 +40,6 @@ namespace detail
struct is_continuable<Continuable<Args...>>
: std::true_type { };
/// Creates an empty callback.
template<typename>
struct create_empty_callback;
template<typename... Args>
struct create_empty_callback<std::function<void(std::function<void(Args...)>&&)>>
{
static auto create()
-> Callback<Args...>
{
return [](Args&&...)
{
};
}
};
template<typename...>
struct continuable_corrector;
@ -131,22 +115,17 @@ public:
_released = true;
// Invoke everything with an empty callback
_callback_insert(detail::create_empty_callback<ForwardFunction>::create());
_callback_insert([](_ATy&&...)
{
});
}
}
/// Deleted copy assign
Continuable& operator= (Continuable const&) = delete;
/// Move construct assign
Continuable& operator= (Continuable&& right)
{
_released = right._released;
right._released = true;
_callback_insert = std::move(right._callback_insert);
return *this;
}
/// Deleted move assign
Continuable& operator= (Continuable&&) = delete;
/// Waits for this continuable and invokes the given callback.
template<typename _CTy>

View File

@ -151,12 +151,25 @@ TEST_CASE("Continuable invocation on destruct", "[Continuable]")
REQUIRE(invoked);
}
SECTION("Continuables are not invoked after transferred")
{
Continuable<> continuable = make_continuable(std::move(invokeable));
{
Continuable<> cache = std::move(continuable);
REQUIRE_FALSE(invoked);
}
REQUIRE(invoked);
}
}
TEST_CASE("Continuable continuation chaining using Continuable::then", "[Continuable]")
{
SECTION("Continuables are invalidated on chaining (no duplicated call)")
{
std::size_t invoked = 0;
//std::size_t invoked = 0;
}
}