Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
TiedTupleOutput.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreTypes.h"
6#include "Templates/Tuple.h"
7
8namespace Algo
9{
10 namespace Private
11 {
12 template <typename... OutputTypes>
14 {
15 template <typename TupleType>
16 void Add(TupleType&& Values)
17 {
18 static_assert(TIsTuple<TupleType>::Value);
19 static_assert(sizeof...(OutputTypes) == TTupleArity<typename TDecay<TupleType>::Type>::Value, "Wrong length of tuple for output");
20
22 [](auto& Output, auto&& Value)
23 {
24 Output.Add(Forward<decltype(Value)>(Value));
25 },
26 Outputs,
28 );
29 }
30
31 TTuple<OutputTypes&...> Outputs;
32 };
33 }
34
35
36 /**
37 * Ties n objects with an Add function, usually containers, into one object with an Add function accepting an n-tuple
38 * that forwards the Add calls.
39 *
40 * This is useful for algorithms such as Algo::Transform and Algo::Copy.
41 *
42 * Example:
43 * TArray<int32> Out1;
44 * TArray<FString> Out2;
45 * TieTupleAdd(Out1, Out2).Add(MakeTuple(42, TEXT("42")));
46 * // Out1 = { 42 }, Out2 = { "42" }
47 *
48 * @param Outputs Objects with an Add() function
49 * @return An object with an Add function that will call Add on the tied elements
50 */
51 template <typename... OutputTypes>
52 Private::TTiedTupleAdder<OutputTypes...> TieTupleAdd(OutputTypes&... Outputs)
53 {
54 return { { Outputs... } };
55 }
56}
Definition Heapify.h:12
Private::TTiedTupleAdder< OutputTypes... > TieTupleAdd(OutputTypes &... Outputs)
void Add(TupleType &&Values)
TTuple< OutputTypes &... > Outputs