mirror of
https://github.com/Naios/continuable.git
synced 2025-12-06 16:56:44 +08:00
Basic skeleton for coroutine_traits
This commit is contained in:
parent
5d95b5c3e3
commit
a85040b0c2
@ -41,6 +41,7 @@
|
||||
#include <continuable/detail/base.hpp>
|
||||
#include <continuable/detail/expected.hpp>
|
||||
#include <continuable/detail/features.hpp>
|
||||
#include <continuable/detail/hints.hpp>
|
||||
#include <continuable/detail/traits.hpp>
|
||||
#include <continuable/detail/types.hpp>
|
||||
#include <continuable/detail/util.hpp>
|
||||
@ -176,5 +177,38 @@ auto create_awaiter(T&& continuable) {
|
||||
} // namespace detail
|
||||
} // namespace cti
|
||||
|
||||
namespace std {
|
||||
namespace experimental {
|
||||
template <typename Data, typename... Args, typename... FunctionArgs>
|
||||
struct coroutine_traits<
|
||||
cti::continuable_base<Data,
|
||||
cti::detail::hints::signature_hint_tag<Args...>>,
|
||||
FunctionArgs...> /*{
|
||||
struct promise_type {
|
||||
// boost::promise<R> p;
|
||||
auto get_return_object() {
|
||||
// return p.get_future();
|
||||
}
|
||||
suspend_always initial_suspend() {
|
||||
return {};
|
||||
}
|
||||
suspend_never final_suspend() {
|
||||
return {};
|
||||
}
|
||||
void set_exception(std::exception_ptr e) {
|
||||
// p.set_exception(std::move(e));
|
||||
}
|
||||
void unhandled_exception() {
|
||||
// p.set_exception(std::current_exception());
|
||||
}
|
||||
template <typename U>
|
||||
void return_value(U&& u) {
|
||||
// p.set_value(std::forward<U>(u));
|
||||
}
|
||||
};
|
||||
}*/;
|
||||
} // namespace experimental
|
||||
} // namespace std
|
||||
|
||||
#endif // CONTINUABLE_HAS_EXPERIMENTAL_COROUTINE
|
||||
#endif // CONTINUABLE_DETAIL_UTIL_HPP_INCLUDED__
|
||||
|
||||
@ -117,6 +117,17 @@ TYPED_TEST(single_dimension_tests, are_awaitable_with_exceptions) {
|
||||
})));
|
||||
}
|
||||
|
||||
// TODO Implement this later
|
||||
//
|
||||
// static cti::continuable<int> async_await() {
|
||||
// co_await cti::make_continuable<void>([](auto&& promise) {
|
||||
// ...
|
||||
// promise.set_value();
|
||||
// });
|
||||
//
|
||||
// co_return 1;
|
||||
// }
|
||||
|
||||
#endif // CONTINUABLE_WITH_NO_EXCEPTIONS
|
||||
|
||||
#endif // CONTINUABLE_HAS_EXPERIMENTAL_COROUTINE
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user