Implements semantics of an input iterator to providing access to elements generated by a given functional object. More...
#include <chsvmemex.h>
Public Types | |
typedef ValueType | value_type |
Type of a value associated with a generating iterator. | |
typedef value_type * | pointer |
Type of a pointer to a value associated with a generating iterator. | |
typedef value_type & | reference |
Type of a reference to a value associated with a generating iterator. | |
typedef std::size_t | size_type |
A type to hold sizes of sets of iterated elements. This is an alias of size_t . | |
typedef std::ptrdiff_t | difference_type |
A type to hold differences in positions associated with generating iterators. The type is an alias to ptrdiff_t . | |
typedef std::input_iterator_tag | iterator_category |
An input iterator category tag, i.e. std::input_iterator_tag . | |
Public Member Functions | |
generating_input_iterator ()=default | |
Default constructor. | |
generating_input_iterator (GeneratingFunctor generator, size_type position_value=0u) noexcept(std::is_nothrow_copy_constructible< GeneratingFunctor >::value) | |
Initializes the created iterator with an instance of a functional object and an optional position specifier. More... | |
generating_input_iterator (size_type position_value) noexcept(std::is_nothrow_default_constructible< GeneratingFunctor >::value) | |
Initializes the created iterator with a default-constructed instance of a functional object and a position specifier. More... | |
generating_input_iterator (const generating_input_iterator &right) | |
The copy constructor. More... | |
generating_input_iterator (generating_input_iterator &&right) | |
The move constructor. More... | |
~generating_input_iterator () | |
The destructor of the generating iterator. | |
generating_input_iterator & | operator= (const generating_input_iterator &right) |
The copy-assignment operator. More... | |
generating_input_iterator & | operator= (generating_input_iterator &&right) |
The move-assignment operator. More... | |
reference | operator* () const |
Dereferences the iterator. More... | |
pointer | operator-> () const |
Dereferences the iterator and provides indirect access to its value. More... | |
generating_input_iterator & | operator++ () noexcept |
Changes position of the iterator once. More... | |
generating_input_iterator | operator++ (int) |
Changes position of the iterator once and returns a copy of the iterator in a state before the increment. More... | |
bool | operator== (const generating_input_iterator &right) noexcept |
Compares positions of two generating iterators for equality. More... | |
bool | operator!= (const generating_input_iterator &right) noexcept |
Compares positions of two generating iterators inequality. More... | |
Implements semantics of an input iterator to providing access to elements generated by a given functional object.
GeneratingFunctor | A type of a functional object called without any parameters to generate elements of the iterator. |
ValueType | A type of a value of the iterator. By default the type corresponds to the return type of the functional object. Otherwise, the return type should be implicitly convertible to ValueType . |
In order to implement the EqualityComparable semantics, the iterator keeps track of its position using an integral positional value. The positional value is changed each time the position of the iterator is changed using increment. Two iterators of the same type, given by an instantiation of generating_input_iterator
, are considered equal if and only if the the positional values are equal.
A reading of a value, i.e. a call to the functional object, only takes place once for a given positional value upon dereferencing of the iterator. Thus, incrementing the iterator more than once without its dereferencing does not cause a call to the functional object nor does it affect the state of the iterator or the functional object in any way other than the increment of the positional value.