Catch more exceptions

This commit is contained in:
Eric Mertens
2023-04-06 12:53:23 -07:00
parent df4c18e47b
commit d137b29608
2 changed files with 29 additions and 12 deletions

View File

@@ -1,6 +1,7 @@
#ifndef AOCPP_GENERATOR_HPP_
#define AOCPP_GENERATOR_HPP_
#include <concepts>
#include <exception>
#include <optional>
#include <utility>
@@ -35,7 +36,7 @@ public:
{
return Generator{handle_type::from_promise(*this)};
}
co::suspend_always initial_suspend() { return {}; }
co::suspend_always initial_suspend() noexcept { return {}; }
co::suspend_always final_suspend() noexcept { return {}; }
void unhandled_exception() { exception_ = std::current_exception(); }
@@ -50,10 +51,10 @@ public:
public:
Generator() noexcept = default;
Generator(handle_type h) : h_(h) {}
Generator(Generator && g) : h_{g.h_} { g.h_ = nullptr; };
Generator(Generator const& g) = delete;
Generator(handle_type h) noexcept : h_(h) {}
Generator(Generator && g) noexcept : h_{std::move(g.h_)} { g.h_ = nullptr; };
Generator & operator=(Generator && rhs) = delete;
Generator(Generator const& g) = delete;
Generator & operator=(Generator const& rhs) = delete;
~Generator() { if (h_) h_.destroy(); }
std::optional<T> operator()()