Commit dfbd8f84 authored by Tom Niget's avatar Tom Niget

Add initial support for generators with parameters

parent 960389fb
......@@ -22,7 +22,7 @@ class Generator
Promise() = default;
std::suspend_always initial_suspend() { return {}; }
std::suspend_always final_suspend() noexcept { return {}; }
std::suspend_always final_suspend() noexcept { final = true; return {}; }
void unhandled_exception() {
std::rethrow_exception(std::move(std::current_exception()));
}
......@@ -47,11 +47,13 @@ class Generator
}
bool finished() {
return !value.has_value();
//return !value.has_value();
return final;
}
private:
value_type value{};
bool final = false;
};
public:
......@@ -68,7 +70,9 @@ public:
Promise::value_type next() {
if (handle) {
if (!handle.promise().finished()) {
handle.resume();
}
return handle.promise().get_value();
}
else {
......@@ -135,7 +139,7 @@ public:
}
std::optional<value_type> py_next() {
return *begin();
return next();
}
private:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment