From dc0d347803ddc8691892e3bae3b68c0ecd890b9a Mon Sep 17 00:00:00 2001 From: BowDown097 <42720004+BowDown097@users.noreply.github.com> Date: Tue, 11 Jun 2024 21:09:08 -0700 Subject: [PATCH] Add result_type member type to dpp::task (#1165) --- include/dpp/coro/async.h | 5 +++++ include/dpp/coro/coroutine.h | 9 +++++++++ include/dpp/coro/task.h | 9 +++++++++ 3 files changed, 23 insertions(+) diff --git a/include/dpp/coro/async.h b/include/dpp/coro/async.h index 2c7c9f13e3..1863498cac 100644 --- a/include/dpp/coro/async.h +++ b/include/dpp/coro/async.h @@ -414,6 +414,11 @@ class async : private detail::async::async_base { using detail::async::async_base::operator=; // use async_base's assignment operator using detail::async::async_base::await_ready; // expose await_ready as public + /** + * @brief The return type of the API call. Defaults to confirmation_callback_t + */ + using result_type = R; + /** * @brief Construct an async object wrapping an object method, the call is made immediately by forwarding to std::invoke and can be awaited later to retrieve the result. * diff --git a/include/dpp/coro/coroutine.h b/include/dpp/coro/coroutine.h index 869882c2c8..18fcac7f1c 100644 --- a/include/dpp/coro/coroutine.h +++ b/include/dpp/coro/coroutine.h @@ -232,6 +232,10 @@ class coroutine : private detail::coroutine::coroutine_base { } public: + /** + * @brief The type of the result produced by this coroutine. + */ + using result_type = R; #ifdef _DOXYGEN_ // :)))) /** * @brief Default constructor, creates an empty coroutine. @@ -334,6 +338,11 @@ class coroutine : private detail::coroutine::coroutine_base { using detail::coroutine::coroutine_base::operator=; // use coroutine_base's assignment operators using detail::coroutine::coroutine_base::await_ready; // expose await_ready as public + /** + * @brief The type of the result produced by this coroutine. + */ + using result_type = void; + /** * @brief Suspend the current coroutine until the coroutine completes. * diff --git a/include/dpp/coro/task.h b/include/dpp/coro/task.h index 5cdf4577d1..74c9f981d7 100644 --- a/include/dpp/coro/task.h +++ b/include/dpp/coro/task.h @@ -335,6 +335,10 @@ class task : private detail::task::task_base { } public: + /** + * @brief The type of the result produced by this task. + */ + using result_type = R; #ifdef _DOXYGEN_ // :) /** * @brief Default constructor, creates a task not bound to a coroutine. @@ -465,6 +469,11 @@ class task : private detail::task::task_base { using detail::task::task_base::cancel; // expose cancel() as public using detail::task::task_base::await_ready; // expose await_ready as public + /** + * @brief The type of the result produced by this task + */ + using result_type = void; + /** * @brief Suspend the current coroutine until the task completes. *