CXXIter 0.2
|
Namespace that contains helper functions providing commonly required functionality when working with CXXIter. More...
Functions | |
template<size_t FIELD_IDX> | |
auto | unzip () |
Helper to construct a lambda that extracts the FIELD_IDX -th element from tuples or pairs passing through the iterator. More... | |
template<typename TDynCastTarget > | |
auto | tryDynCast () |
Helper to construct a filterMap() lambda that takes a pointer, dyncasts it to the requested type and returns a std::optional<TDynCastTarget> with the result if the cast was successfull. More... | |
template<typename TItem , typename TFilterExtractFn > | |
auto | filterIsOneOf (TFilterExtractFn filterExtractFn, const std::initializer_list< TItem > &acceptedValues) |
Helper that constructs a filter() lambda that filters the iterator elements by calling the given filterExtractFn on each element and then checking whether that is contained in the given list of acceptedValues . More... | |
template<typename TItem > | |
auto | filterIsOneOf (const std::initializer_list< TItem > &acceptedValues) |
Helper that constructs a filter() lambda that filters an iterator's elements by checking whether they are contained in the given list of acceptedValues . More... | |
Namespace that contains helper functions providing commonly required functionality when working with CXXIter.
These functions are small helper functions that can be used in conjunction with the iterator API interface. For example by constructing lambdas for reusable tasks with a clear and concise API, instead of copying the lambda code itself everywhere it is needed.
auto CXXIter::fn::filterIsOneOf | ( | const std::initializer_list< TItem > & | acceptedValues | ) |
Helper that constructs a filter() lambda that filters an iterator's elements by checking whether they are contained in the given list of acceptedValues
.
acceptedValues | List of values that are allowed to remain in the iterator. |
acceptedValues
.Usage Example:
auto CXXIter::fn::filterIsOneOf | ( | TFilterExtractFn | filterExtractFn, |
const std::initializer_list< TItem > & | acceptedValues | ||
) |
Helper that constructs a filter() lambda that filters the iterator elements by calling the given filterExtractFn
on each element and then checking whether that is contained in the given list of acceptedValues
.
filterExtractFn | Lambda that extracts a value for each iterator element, which is then searched for in the list of acceptedValues . |
acceptedValues | List of comparison-values that are allowed to remain in the iterator. |
acceptedValues
.Usage Example:
auto CXXIter::fn::tryDynCast | ( | ) |
Helper to construct a filterMap() lambda that takes a pointer, dyncasts it to the requested type and returns a std::optional<TDynCastTarget>
with the result if the cast was successfull.
You can use this shortcut everywhere, where a lambda is required that takes an element and returns an std::optional<TDynCastTarget>
that is set only when the dynamic_cast()
was successful.
TDynCastTarget | Type that the elements that are passed to the generated lambda should be cast to. |
dynamic_cast()
a given element to TDynCastTarget
and returns a std::optional<TDynCastTarget>
with the result if the cast was successful. And none
if it failed.Usage Example:
auto CXXIter::fn::unzip | ( | ) |
Helper to construct a lambda that extracts the FIELD_IDX
-th element from tuples or pairs passing through the iterator.
You can use this shortcut everywhere, where a lambda is required that takes a tuple or pair and returns their FIELD_IDX
-th element.
FIELD_IDX | Index of the field to extract. |
FIELD_IDX
-th element.Usage Example: