44 lines
1.0 KiB
C++
44 lines
1.0 KiB
C++
//
|
|
// Created by selim on 20.04.2022.
|
|
//
|
|
|
|
#ifndef AUTOCAT_GNOME_CORO_H
|
|
#define AUTOCAT_GNOME_CORO_H
|
|
|
|
#include <exception>
|
|
#include <iostream>
|
|
|
|
#if __cpp_lib_coroutine
|
|
#include <coroutine>
|
|
namespace corons = std;
|
|
#else
|
|
#include <experimental/coroutine>
|
|
namespace corons = std::experimental;
|
|
#endif
|
|
|
|
template<typename... Args>
|
|
struct corons::coroutine_traits<void, Args...> {
|
|
struct promise_type {
|
|
void get_return_object() noexcept {}
|
|
|
|
corons::suspend_never initial_suspend() const noexcept {
|
|
return {};
|
|
}
|
|
corons::suspend_never final_suspend() const noexcept {
|
|
return {};
|
|
}
|
|
|
|
void return_void() noexcept {}
|
|
|
|
void unhandled_exception() noexcept {
|
|
try {
|
|
std::rethrow_exception(std::current_exception());
|
|
} catch (std::exception& ex) {
|
|
std::cout << "Unhandled exception (in void coroutine) detected: " << ex.what() << std::endl;
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
#endif //AUTOCAT_GNOME_CORO_H
|