MCRO
C++23 utilities for Unreal Engine.
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages Concepts
Mcro::Range::OutputToMap< Target > Class Template Reference

Output a range of tuples or range of ranges with at least 2 elements to an already existing TMap. More...

#include <Conversion.h>

Public Member Functions

 OutputToMap (Target &target)
 

Friends

template<CRangeMember From, CTupleConvertsToArgs< KeyType, ValueType > = TRangeElementType<From>>
Target & operator| (From &&range, OutputToMap &&functor)
 

Detailed Description

template<CIsTemplate< TMap > Target>
class Mcro::Range::OutputToMap< Target >

Output a range of tuples or range of ranges with at least 2 elements to an already existing TMap.

This functor will iterate over the entire input range and copy its values to the existing TMap one-by-one with its Add function.

When working with range-of-ranges then ranges which doesn't have at least two elements will be silently ignored.

usage (from tuples):

using namespace ranges;
TArray<int32> MyKeyArray {1, 2, 3, 4, 5};
TArray<FString> MyValueArray {TEXT_"foo", TEXT_"bar"};
auto result = views::zip(MyKeyArray, views::cycle(MyValueArray))
| RenderAsMap();
// -> TMap<int32, FString> {{1, "foo"}, {2, "bar"}, {3, "foo"}, {4, "bar"}, {5, "foo"}}
#define TEXT_
A convenience alternative to Unreal's own TEXT macro but this one doesn't require parenthesis around ...
Definition TextMacros.h:51

usage (from inner-ranges):

using namespace ranges;
auto result = views::ints(0, 9)
| views::chunk(2)
// -> TMap<int32, int32> {{0, 1}, {2, 3}, {4, 5}, {6, 7}}
// notice how 8 is discarded from the end, as that range didn't have 2 items
Render a range of tuples or range of ranges with at least 2 elements as a TMap.
Definition Conversion.h:392
Template Parameters
TargetA TMap. Its key-value types will be deduced from the target output map.

Definition at line 506 of file Conversion.h.

Constructor & Destructor Documentation

◆ OutputToMap()

template<CIsTemplate< TMap > Target>
Mcro::Range::OutputToMap< Target >::OutputToMap ( Target & target)
inline

Definition at line 513 of file Conversion.h.

Friends And Related Symbol Documentation

◆ operator|

template<CIsTemplate< TMap > Target>
template<CRangeMember From, CTupleConvertsToArgs< KeyType, ValueType > = TRangeElementType<From>>
Target & operator| ( From && range,
OutputToMap< Target > && functor )
friend

Definition at line 519 of file Conversion.h.


The documentation for this class was generated from the following file: