Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::Generator< T >::iterator Class Reference

Single-pass input iterator over the yielded sequence. More...

#include <ah-generator.H>

Public Types

using iterator_category = std::input_iterator_tag
 Category.
 
using value_type = std::remove_reference_t< T >
 Element type.
 
using difference_type = std::ptrdiff_t
 Distance type.
 
using reference = T &
 Reference type.
 
using pointer = std::add_pointer_t< T >
 Pointer type.
 

Public Member Functions

 iterator () noexcept=default
 Construct a singular (past-the-end-compatible) iterator.
 
 iterator (Handle h) noexcept
 Construct from a coroutine handle (internal use).
 
iterator & operator++ ()
 Resume the coroutine to its next co_yield (pre-increment).
 
void operator++ (int)
 Resume the coroutine to its next co_yield (post-increment).
 
reference operator* () const noexcept
 Dereference to the most recently yielded value.
 
pointer operator-> () const noexcept
 Member access on the most recently yielded value.
 
bool done () const noexcept
 True when the coroutine has run to completion (or was never begun).
 

Private Attributes

Handle handle_ {}
 

Friends

bool operator== (const iterator &it, std::default_sentinel_t) noexcept
 Compare against the end sentinel: equal once the sequence is done.
 

Detailed Description

template<class T>
class Aleph::Generator< T >::iterator

Single-pass input iterator over the yielded sequence.

Obtained from Generator::begin(); compares against std::default_sentinel (returned by Generator::end()) to detect exhaustion. Advancing the iterator resumes the coroutine to its next co_yield (or to completion).

Definition at line 217 of file ah-generator.H.

Member Typedef Documentation

◆ difference_type

template<class T >
using Aleph::Generator< T >::iterator::difference_type = std::ptrdiff_t

Distance type.

Definition at line 224 of file ah-generator.H.

◆ iterator_category

template<class T >
using Aleph::Generator< T >::iterator::iterator_category = std::input_iterator_tag

Category.

Definition at line 222 of file ah-generator.H.

◆ pointer

template<class T >
using Aleph::Generator< T >::iterator::pointer = std::add_pointer_t<T>

Pointer type.

Definition at line 226 of file ah-generator.H.

◆ reference

template<class T >
using Aleph::Generator< T >::iterator::reference = T &

Reference type.

Definition at line 225 of file ah-generator.H.

◆ value_type

template<class T >
using Aleph::Generator< T >::iterator::value_type = std::remove_reference_t<T>

Element type.

Definition at line 223 of file ah-generator.H.

Constructor & Destructor Documentation

◆ iterator() [1/2]

template<class T >
Aleph::Generator< T >::iterator::iterator ( )
defaultnoexcept

Construct a singular (past-the-end-compatible) iterator.

◆ iterator() [2/2]

template<class T >
Aleph::Generator< T >::iterator::iterator ( Handle  h)
inlineexplicitnoexcept

Construct from a coroutine handle (internal use).

Definition at line 232 of file ah-generator.H.

Member Function Documentation

◆ done()

template<class T >
bool Aleph::Generator< T >::iterator::done ( ) const
inlinenoexcept

True when the coroutine has run to completion (or was never begun).

Definition at line 277 of file ah-generator.H.

References Aleph::blossom_maximum_cardinality_matching(), and Aleph::Generator< T >::iterator::handle_.

Referenced by Aleph::Generator< T >::iterator::operator++().

◆ operator*()

template<class T >
reference Aleph::Generator< T >::iterator::operator* ( ) const
inlinenoexcept

Dereference to the most recently yielded value.

Definition at line 265 of file ah-generator.H.

References Aleph::Generator< T >::iterator::handle_.

◆ operator++() [1/2]

template<class T >
iterator & Aleph::Generator< T >::iterator::operator++ ( )
inline

Resume the coroutine to its next co_yield (pre-increment).

Returns
*this, now referring to the next value (or exhausted).
Exceptions
std::domain_errorif the iterator is already at end(). Resuming a coroutine past its final suspend point is undefined behavior, so this is checked explicitly rather than left to manifest as UB.
Whateverthe coroutine body threw before its next co_yield, if anything.

Definition at line 243 of file ah-generator.H.

References ah_domain_error_if, Aleph::Generator< T >::iterator::done(), and Aleph::Generator< T >::iterator::handle_.

◆ operator++() [2/2]

template<class T >
void Aleph::Generator< T >::iterator::operator++ ( int  )
inline

Resume the coroutine to its next co_yield (post-increment).

Returns void rather than the pre-increment value: single-pass input iterators cannot meaningfully support *it++ (there is no previous value left to dereference once the coroutine has resumed), matching the standard library's own single-pass generator iterators.

Exceptions
Sameas operator++().

Definition at line 262 of file ah-generator.H.

◆ operator->()

template<class T >
pointer Aleph::Generator< T >::iterator::operator-> ( ) const
inlinenoexcept

Member access on the most recently yielded value.

Definition at line 271 of file ah-generator.H.

References Aleph::Generator< T >::iterator::handle_.

Friends And Related Symbol Documentation

◆ operator==

template<class T >
bool operator== ( const iterator &  it,
std::default_sentinel_t   
)
friend

Compare against the end sentinel: equal once the sequence is done.

Definition at line 283 of file ah-generator.H.

Member Data Documentation

◆ handle_


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