CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
CeresEngine::Generator< T >::Promise Class Referencefinal

The promise type used to implement to coroutine. More...

Public Types

using Value = std::remove_reference_t< T >
 The value type returned by the generator.
 
using Reference = std::conditional_t< std::is_reference_v< T >, T, T & >
 A reference of Value.
 
using Pointer = Value *
 A pointer of Value.
 

Public Member Functions

 Promise ()=default
 Creates a new promise object.
 
Generator get_return_object () noexcept
 Creates a new Generator object.
 
constexpr suspend_always initial_suspend () const noexcept
 
constexpr suspend_always final_suspend () const noexcept
 
template<typename U = T, std::enable_if_t<!std::is_rvalue_reference< U >::value, int > = 0>
suspend_always yield_value (std::remove_reference_t< T > &aValue) noexcept
 Yields a new value to the generator.
 
template<typename U = T, std::enable_if_t<!std::is_rvalue_reference< U >::value &&!std::is_const_v< U >, int > = 0>
suspend_always yield_value (const std::remove_reference_t< T > &aValue) noexcept
 Yields a new value to the generator.
 
void unhandled_exception () noexcept
 A method called internally by the compiler when an exception is thrown in the coroutine.
 
void return_void () noexcept
 A method called internally by the compiler when the coroutine successfully finishes.
 
template<typename U >
suspend_never await_transform (U &&value)=delete
 Don't allow any use of 'co_await' inside the generator coroutine.
 
Reference getValue () const noexcept
 
void rethrow ()
 If an exception was thrown in the coroutine, rethrows it.
 

Private Attributes

Pointer mValue = nullptr
 The value returned by the last continuation of the coroutine.
 
std::exception_ptr mException = nullptr
 The exception throw by the coroutine.
 

Detailed Description

template<typename T>
class CeresEngine::Generator< T >::Promise

The promise type used to implement to coroutine.

Member Typedef Documentation

◆ Pointer

template<typename T >
using CeresEngine::Generator< T >::Promise::Pointer = Value*

A pointer of Value.

◆ Reference

template<typename T >
using CeresEngine::Generator< T >::Promise::Reference = std::conditional_t<std::is_reference_v<T>, T, T&>

A reference of Value.

◆ Value

template<typename T >
using CeresEngine::Generator< T >::Promise::Value = std::remove_reference_t<T>

The value type returned by the generator.

Constructor & Destructor Documentation

◆ Promise()

template<typename T >
CeresEngine::Generator< T >::Promise::Promise ( )
default

Creates a new promise object.

Member Function Documentation

◆ await_transform()

template<typename T >
template<typename U >
suspend_never CeresEngine::Generator< T >::Promise::await_transform ( U &&  value)
delete

Don't allow any use of 'co_await' inside the generator coroutine.

Template Parameters
Uthe value type awaited
Parameters
valueThe value awaited
Returns
suspend_never

◆ final_suspend()

template<typename T >
constexpr suspend_always CeresEngine::Generator< T >::Promise::final_suspend ( ) const
inlineconstexprnoexcept
Returns
suspend_always

◆ get_return_object()

template<typename T >
Generator CeresEngine::Generator< T >::Promise::get_return_object ( )
inlinenoexcept

Creates a new Generator object.

This is caled internally by the compiler when creating a new generator.

Returns
The generator object

◆ getValue()

template<typename T >
Reference CeresEngine::Generator< T >::Promise::getValue ( ) const
inlinenoexcept
Returns
A reference to the last yielded value

◆ initial_suspend()

template<typename T >
constexpr suspend_always CeresEngine::Generator< T >::Promise::initial_suspend ( ) const
inlineconstexprnoexcept
Returns
suspend_always

◆ rethrow()

template<typename T >
void CeresEngine::Generator< T >::Promise::rethrow ( )
inline

If an exception was thrown in the coroutine, rethrows it.

If no exception was thrown, this method does nothing.

◆ return_void()

template<typename T >
void CeresEngine::Generator< T >::Promise::return_void ( )
inlinenoexcept

A method called internally by the compiler when the coroutine successfully finishes.

◆ unhandled_exception()

template<typename T >
void CeresEngine::Generator< T >::Promise::unhandled_exception ( )
inlinenoexcept

A method called internally by the compiler when an exception is thrown in the coroutine.

This will setup the execption to that it is thrown when calling operator++.

◆ yield_value() [1/2]

template<typename T >
template<typename U = T, std::enable_if_t<!std::is_rvalue_reference< U >::value &&!std::is_const_v< U >, int > = 0>
suspend_always CeresEngine::Generator< T >::Promise::yield_value ( const std::remove_reference_t< T > &  aValue)
inlinenoexcept

Yields a new value to the generator.

Template Parameters
Uthe value type
Parameters
aValueThe value to be yielded to the generator
Returns
suspend_always

◆ yield_value() [2/2]

template<typename T >
template<typename U = T, std::enable_if_t<!std::is_rvalue_reference< U >::value, int > = 0>
suspend_always CeresEngine::Generator< T >::Promise::yield_value ( std::remove_reference_t< T > &  aValue)
inlinenoexcept

Yields a new value to the generator.

Template Parameters
Uthe value type
Parameters
aValueThe value to be yielded to the generator
Returns
suspend_always

Member Data Documentation

◆ mException

template<typename T >
std::exception_ptr CeresEngine::Generator< T >::Promise::mException = nullptr
private

The exception throw by the coroutine.

If no exception was thrown, this is ´nullptr`.

◆ mValue

template<typename T >
Pointer CeresEngine::Generator< T >::Promise::mValue = nullptr
private

The value returned by the last continuation of the coroutine.


The documentation for this class was generated from the following file: