CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
CeresEngine::AsyncGenerator< T, Lockable >::Iterator Class Referencefinal

An iterator type that allows the caller to iterate over the results of a generator. More...

Public Types

using iterator_category = std::input_iterator_tag
 
using difference_type = std::ptrdiff_t
 
using value_type = T
 
using reference = T const &
 
using pointer = T const *
 

Public Member Functions

 Iterator () noexcept
 Iterator needs to be default-constructible to satisfy the Range concept.
 
 Iterator (std::nullptr_t) noexcept
 Initialize an past-the-end iterator.
 
 Iterator (const AsyncCoroutineHandle handle) noexcept
 Creates a new Iterator object with an attached coroutine handle.
 
bool operator== (const Iterator &rhs) const noexcept
 Check if two iterator are equal.
 
bool operator!= (const Iterator &rhs) const noexcept
 Check if two iterator are not equal.
 
Iterator operator++ (int)=delete
 Post increment is not supported.
 
Iteratoroperator++ ()
 Resumes the generator coroutine and runs until the next value is yielded by it.
 
reference operator* () noexcept
 Dereferences the iterator and returns a reference to the last yielded value.
 
reference operator* () const noexcept
 Dereferences the iterator and returns a reference to the last yielded value.
 
pointer operator-> () noexcept
 Dereferences the iterator and returns a pointer to the last yielded value.
 
pointer operator-> () const noexcept
 Dereferences the iterator and returns a pointer to the last yielded value.
 
bool await_ready () const noexcept
 
void await_suspend (AsyncCoroutineHandle rh) noexcept
 
Iteratorawait_resume ()
 

Private Attributes

PromisemPromise = nullptr
 

Detailed Description

template<typename T, typename Lockable = Mutex>
class CeresEngine::AsyncGenerator< T, Lockable >::Iterator

An iterator type that allows the caller to iterate over the results of a generator.

Member Typedef Documentation

◆ difference_type

template<typename T , typename Lockable = Mutex>
using CeresEngine::AsyncGenerator< T, Lockable >::Iterator::difference_type = std::ptrdiff_t

◆ iterator_category

template<typename T , typename Lockable = Mutex>
using CeresEngine::AsyncGenerator< T, Lockable >::Iterator::iterator_category = std::input_iterator_tag

◆ pointer

template<typename T , typename Lockable = Mutex>
using CeresEngine::AsyncGenerator< T, Lockable >::Iterator::pointer = T const*

◆ reference

template<typename T , typename Lockable = Mutex>
using CeresEngine::AsyncGenerator< T, Lockable >::Iterator::reference = T const&

◆ value_type

template<typename T , typename Lockable = Mutex>
using CeresEngine::AsyncGenerator< T, Lockable >::Iterator::value_type = T

Constructor & Destructor Documentation

◆ Iterator() [1/3]

template<typename T , typename Lockable = Mutex>
CeresEngine::AsyncGenerator< T, Lockable >::Iterator::Iterator ( )
inlinenoexcept

Iterator needs to be default-constructible to satisfy the Range concept.

◆ Iterator() [2/3]

template<typename T , typename Lockable = Mutex>
CeresEngine::AsyncGenerator< T, Lockable >::Iterator::Iterator ( std::nullptr_t  )
inlineexplicitnoexcept

Initialize an past-the-end iterator.

◆ Iterator() [3/3]

template<typename T , typename Lockable = Mutex>
CeresEngine::AsyncGenerator< T, Lockable >::Iterator::Iterator ( const AsyncCoroutineHandle  handle)
inlineexplicitnoexcept

Creates a new Iterator object with an attached coroutine handle.

Parameters
handleThe coroutine handle

Member Function Documentation

◆ await_ready()

template<typename T , typename Lockable = Mutex>
bool CeresEngine::AsyncGenerator< T, Lockable >::Iterator::await_ready ( ) const
inlinenoexcept

◆ await_resume()

template<typename T , typename Lockable = Mutex>
Iterator & CeresEngine::AsyncGenerator< T, Lockable >::Iterator::await_resume ( )
inline

◆ await_suspend()

template<typename T , typename Lockable = Mutex>
void CeresEngine::AsyncGenerator< T, Lockable >::Iterator::await_suspend ( AsyncCoroutineHandle  rh)
inlinenoexcept

◆ operator!=()

template<typename T , typename Lockable = Mutex>
bool CeresEngine::AsyncGenerator< T, Lockable >::Iterator::operator!= ( const Iterator rhs) const
inlinenoexcept

Check if two iterator are not equal.

See operator== for more details.

Parameters
rhsThe iterator to check against
Returns
true if the generator has reached the end.

◆ operator*() [1/2]

template<typename T , typename Lockable = Mutex>
reference CeresEngine::AsyncGenerator< T, Lockable >::Iterator::operator* ( ) const
inlinenoexcept

Dereferences the iterator and returns a reference to the last yielded value.

Returns
A reference to the latest element

◆ operator*() [2/2]

template<typename T , typename Lockable = Mutex>
reference CeresEngine::AsyncGenerator< T, Lockable >::Iterator::operator* ( )
inlinenoexcept

Dereferences the iterator and returns a reference to the last yielded value.

Returns
A reference to the latest element

◆ operator++() [1/2]

template<typename T , typename Lockable = Mutex>
Iterator & CeresEngine::AsyncGenerator< T, Lockable >::Iterator::operator++ ( )
inline

Resumes the generator coroutine and runs until the next value is yielded by it.

Returns
*this.

◆ operator++() [2/2]

template<typename T , typename Lockable = Mutex>
Iterator CeresEngine::AsyncGenerator< T, Lockable >::Iterator::operator++ ( int  )
delete

Post increment is not supported.

◆ operator->() [1/2]

template<typename T , typename Lockable = Mutex>
pointer CeresEngine::AsyncGenerator< T, Lockable >::Iterator::operator-> ( ) const
inlinenoexcept

Dereferences the iterator and returns a pointer to the last yielded value.

Returns
A pointer to the latest element

◆ operator->() [2/2]

template<typename T , typename Lockable = Mutex>
pointer CeresEngine::AsyncGenerator< T, Lockable >::Iterator::operator-> ( )
inlinenoexcept

Dereferences the iterator and returns a pointer to the last yielded value.

Returns
A pointer to the latest element

◆ operator==()

template<typename T , typename Lockable = Mutex>
bool CeresEngine::AsyncGenerator< T, Lockable >::Iterator::operator== ( const Iterator rhs) const
inlinenoexcept

Check if two iterator are equal.

Since a generator sequence is potentially infinite, this only checks if there is any value remaining in the sequence.

Parameters
rhsThe iterator to check against
Returns
true if there is at least one more value in the generator sequence.

Member Data Documentation

◆ mPromise

template<typename T , typename Lockable = Mutex>
Promise* CeresEngine::AsyncGenerator< T, Lockable >::Iterator::mPromise = nullptr
private

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