D++ (DPP)
C++ Discord API Bot Library
dpp::detail::coroutine::promise_t< R > Struct Template Reference

Promise type for coroutine. More...

#include <coroutine.h>

+ Collaboration diagram for dpp::detail::coroutine::promise_t< R >:

Public Member Functions

final_awaiter< R > final_suspend () const noexcept
 Function called by the standard library when reaching the end of a coroutine. More...
 
std_coroutine::suspend_always initial_suspend () const noexcept
 Function called by the standard library when the coroutine start. More...
 
void unhandled_exception () noexcept
 Function called when an exception escapes the coroutine. More...
 
void return_value (R &&expr) noexcept(std::is_nothrow_move_constructible_v< R >)
 Function called by the standard library when the coroutine co_returns a value. More...
 
void return_value (const R &expr) noexcept(std::is_nothrow_copy_constructible_v< R >)
 Function called by the standard library when the coroutine co_returns a value. More...
 
template<typename T >
requires (!std::is_same_v<R, std::remove_cvref_t<T>> && std::convertible_to<T, R>)
void return_value (T &&expr) noexcept(std::is_nothrow_convertible_v< T, R >)
 Function called by the standard library when the coroutine co_returns a value. More...
 
dpp::coroutine< R > get_return_object ()
 Function called to get the coroutine object. More...
 

Public Attributes

std_coroutine::coroutine_handle parent {nullptr}
 Handle of the coroutine co_await-ing this coroutine. More...
 
std::optional< R > result {}
 Return value of the coroutine. More...
 
std::exception_ptr exception {nullptr}
 Pointer to an uncaught exception thrown by the coroutine. More...
 

Detailed Description

template<typename R>
struct dpp::detail::coroutine::promise_t< R >

Promise type for coroutine.

Member Function Documentation

◆ final_suspend()

template<typename R >
final_awaiter< R > dpp::detail::coroutine::promise_t< R >::final_suspend
noexcept

Function called by the standard library when reaching the end of a coroutine.

Returns
final_awaiter<R> Resumes any coroutine co_await-ing on this

◆ get_return_object()

template<typename R >
dpp::coroutine< R > dpp::detail::coroutine::promise_t< R >::get_return_object ( )
inline

Function called to get the coroutine object.

◆ initial_suspend()

template<typename R >
std_coroutine::suspend_always dpp::detail::coroutine::promise_t< R >::initial_suspend ( ) const
inlinenoexcept

Function called by the standard library when the coroutine start.

Returns
std::suspend_always Always suspend at the start, for a lazy start

◆ return_value() [1/3]

template<typename R >
void dpp::detail::coroutine::promise_t< R >::return_value ( const R &  expr)
inlinenoexcept

Function called by the standard library when the coroutine co_returns a value.

Stores the value internally to hand to the caller when it resumes.

Parameters
exprThe value given to co_return

◆ return_value() [2/3]

template<typename R >
void dpp::detail::coroutine::promise_t< R >::return_value ( R &&  expr)
inlinenoexcept

Function called by the standard library when the coroutine co_returns a value.

Stores the value internally to hand to the caller when it resumes.

Parameters
exprThe value given to co_return

◆ return_value() [3/3]

template<typename R >
template<typename T >
requires (!std::is_same_v<R, std::remove_cvref_t<T>> && std::convertible_to<T, R>)
void dpp::detail::coroutine::promise_t< R >::return_value ( T &&  expr)
inlinenoexcept

Function called by the standard library when the coroutine co_returns a value.

Stores the value internally to hand to the caller when it resumes.

Parameters
exprThe value given to co_return

◆ unhandled_exception()

template<typename R >
void dpp::detail::coroutine::promise_t< R >::unhandled_exception ( )
inlinenoexcept

Function called when an exception escapes the coroutine.

Stores the exception to throw to the co_await-er

Member Data Documentation

◆ exception

template<typename R >
std::exception_ptr dpp::detail::coroutine::promise_t< R >::exception {nullptr}

Pointer to an uncaught exception thrown by the coroutine.

◆ parent

template<typename R >
std_coroutine::coroutine_handle dpp::detail::coroutine::promise_t< R >::parent {nullptr}

Handle of the coroutine co_await-ing this coroutine.

◆ result

template<typename R >
std::optional<R> dpp::detail::coroutine::promise_t< R >::result {}

Return value of the coroutine.

D++ Library version 10.0.35D++ Library version 10.0.34D++ Library version 10.0.33D++ Library version 10.0.32D++ Library version 10.0.31D++ Library version 10.0.30D++ Library version 10.0.29D++ Library version 10.0.28D++ Library version 10.0.27D++ Library version 10.0.26D++ Library version 10.0.25D++ Library version 10.0.24D++ Library version 10.0.23D++ Library version 10.0.22D++ Library version 10.0.21D++ Library version 10.0.20D++ Library version 10.0.19D++ Library version 10.0.18D++ Library version 10.0.17D++ Library version 10.0.16D++ Library version 10.0.15D++ Library version 10.0.14D++ Library version 10.0.13D++ Library version 10.0.12D++ Library version 10.0.11D++ Library version 10.0.10D++ Library version 10.0.9D++ Library version 10.0.8D++ Library version 10.0.7D++ Library version 10.0.6D++ Library version 10.0.5D++ Library version 10.0.4D++ Library version 10.0.3D++ Library version 10.0.2D++ Library version 10.0.1D++ Library version 10.0.0D++ Library version 9.0.19D++ Library version 9.0.18D++ Library version 9.0.17D++ Library version 9.0.16D++ Library version 9.0.15D++ Library version 9.0.14D++ Library version 9.0.13D++ Library version 9.0.12D++ Library version 9.0.11D++ Library version 9.0.10D++ Library version 9.0.9D++ Library version 9.0.8D++ Library version 9.0.7D++ Library version 9.0.6D++ Library version 9.0.5D++ Library version 9.0.4D++ Library version 9.0.3D++ Library version 9.0.2D++ Library version 9.0.1D++ Library version 9.0.0D++ Library version 1.0.2D++ Library version 1.0.1D++ Library version 1.0.0