#include <foreach.h>
ForEachIterator is a helper template for the implementation of a foreach iterator (see maxon::Iterable). You can use it as public base class for your foreach iterator class with the template argument ITERATOR being your class as in
This relieves you from the need to declare a IsForEachIterator type alias, and it adds some functions such as ToString and Contains. However note that these functions are non-const, i.e., they use the current iterator for the iteration so that it will point to another iteration value after function completion.
ITERATOR | The class which implements the foreach protocol, ForEachIterator should be its base class. |
SUPER | This is used as base class of ForEachIterator. |
Classes | |
class | Wrapper |
Public Types | |
using | IsForEachIterator = std::true_type |
Public Member Functions | |
template<typename... ARGS> | |
MAXON_ATTRIBUTE_FORCE_INLINE | ForEachIterator (ARGS &&... args) |
String | ToString (const FormatStatement *formatStatement=nullptr) |
template<typename T > | |
ITERATOR & | Find (const T &v) |
template<typename T > | |
Int | FindIndex (const T &v) |
template<typename T > | |
MAXON_ATTRIBUTE_FORCE_INLINE Bool | Contains (const T &v) |
MAXON_ATTRIBUTE_FORCE_INLINE Wrapper | begin () |
Static Public Member Functions | |
static MAXON_ATTRIBUTE_FORCE_INLINE | PRIVATE_MAXON_RBF_SENTINEL (Wrapper) end() |
using IsForEachIterator = std::true_type |
This marker indicates that this ForEachIterator supports the foreach protocol (see Iterable).
|
explicit |
ITERATOR& Find | ( | const T & | v | ) |
Iterates over this foreach iterator until an iteration value is found which equals v. The function advances this iterator. Example:
[in] | v | Value for comparison. |
Int FindIndex | ( | const T & | v | ) |
Iterates over this foreach iterator until an iteration value is found which equals v, and returns the number of needed iterations or a negative value if v couldn't be found.
[in] | v | Value for comparison. |
MAXON_ATTRIBUTE_FORCE_INLINE Bool Contains | ( | const T & | v | ) |
Iterates over this foreach iterator until an iteration value is found which equals v and returns true on success, or false if v couldn't be found.
[in] | v | Value for comparison. |
MAXON_ATTRIBUTE_FORCE_INLINE Wrapper begin | ( | ) |
|
static |