I have two TArray objects containing FStrings. They’re both the same length. I want to use some method to combine the two arrays into an array of pairs/tuples. This is similar to how the zip function works in Python or boost.
I tried doing it with std::transform, but I’m struggling to understand the correct usage of this function. I know there’s also a Algo::Transform in UE C++ API that’s suppose to do similar thing.
Here’s my failed attempt:
TArray<FString> LeftImages;
TArray<FString> RightImages;
// Combine the left and right image paths into pairs
TArray<TTuple<FString, FString>> ImagePathPairs;
std::transform(LeftImages.begin(), LeftImages.end(), RightImages.begin(),
std::back_inserter(ImagePathPairs),
[](const FString& aa, const FString& bb)
{
return TTuple<FString, FString>(aa, bb);
});
easiest to just do a loop probably. Transform looks like it applies the given function that is the third argument, to the given input that is the first argument, and outputs it as the out parameter second argument.