Skip to content

LiteFX::CovariantIterator

Wraps an iterator and returns covariants of type T of the iterated value.

Synopsis

Declared in <litefx/containers.hpp>

template<typename T>
struct CovariantIterator;

Description

This iterator uses type erasure to hide the actual iterated types from the interface. This allows to iterate a range of class instances as a range of base class instances. However, due to the type erasure, each iteration requires a virtual indirection, resulting in slightly lower performance. Limit the use of this iterator to base class interfaces and return a reference to the actual underlying range in child classes instead for most performance.

Type Aliases

NameDescription
difference_type The type that expresses the difference between two iterators.
iterator_category The category of the iterator.
pointer The type of a pointer returned by the iterator.
value_type The type of the value that is iterated.

Member Functions

NameDescription
CovariantIterator [constructor]Constructors
~CovariantIterator [destructor]Releases the iterator.
operator= Assignment operators
operator* Returns a reference of the value at the current iterator position.
operator++ Increment operators
operator-> Returns a pointer to the value at the current iterator position.
operator== Checks if two iterators are equal, i.e. they are pointing to the same value.

Template Parameters

NameDescription
TThe type returned by the iterator, that is covariant to the actual iterated type.

See Also

Enumerable