From 9a194343f3cff09091b7f48ff0b5169f8b25b8dc Mon Sep 17 00:00:00 2001 From: q66 Date: Mon, 6 Mar 2017 02:09:52 +0100 Subject: [PATCH] operator bool on coroutine should be inverse --- ostd/coroutine.hh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ostd/coroutine.hh b/ostd/coroutine.hh index 98f45a4..d7e959d 100644 --- a/ostd/coroutine.hh +++ b/ostd/coroutine.hh @@ -342,7 +342,7 @@ struct coroutine: detail::coro_base { } operator bool() const { - return this->p_ctx.is_done(); + return !this->p_ctx.is_done(); } R operator()(A ...args) { @@ -371,7 +371,7 @@ struct generator: input_range> { generator(F &&func, size_t ss = COROUTINE_DEFAULT_STACK_SIZE): p_ptr(new coroutine{std::forward(func), ss}) { - p_item = (*p_ptr)(); + pop_front(); } bool empty() const { @@ -379,7 +379,7 @@ struct generator: input_range> { } void pop_front() { - if (!*p_ptr) { + if (*p_ptr) { p_item = (*p_ptr)(); } else { p_item = std::nullopt;