6#include <unordered_set>
38 template<
size_t FIELD_IDX>
40 return [](
const auto& item) {
return std::get<FIELD_IDX>(item); };
75 template<
typename TDynCastTarget>
77 return [](
auto itemPtr) -> std::optional<TDynCastTarget> {
78 TDynCastTarget targetPtr =
dynamic_cast<TDynCastTarget
>(itemPtr);
79 if(targetPtr ==
nullptr) {
return {}; }
119 template<
typename TItem,
typename TFilterExtractFn>
120 auto filterIsOneOf(TFilterExtractFn filterExtractFn,
const std::initializer_list<TItem>& acceptedValues) {
121 std::unordered_set<TItem> _acceptedValues = acceptedValues;
122 return [_acceptedValues = std::move(_acceptedValues), filterExtractFn](
const auto& item) {
123 return _acceptedValues.contains(filterExtractFn(item));
156 template<
typename TItem>
158 return filterIsOneOf<TItem>([](
const auto& item) {
return item; }, acceptedValues);
Namespace that contains helper functions providing commonly required functionality when working with ...
auto tryDynCast()
Helper to construct a filterMap() lambda that takes a pointer, dyncasts it to the requested type and ...
auto unzip()
Helper to construct a lambda that extracts the FIELD_IDX-th element from tuples or pairs passing thro...
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 filt...