UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
ForEach.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/Invoke.h"
7
8namespace Algo
9{
17 template <typename InT, typename PredicateT, typename CallableT>
18 void ForEachIf(InT&& Input, PredicateT Predicate, CallableT Callable)
19 {
20 for (auto& Value : Input)
21 {
22 if (Invoke(Predicate, Value))
23 {
24 Invoke(Callable, Value);
25 }
26 }
27 }
28
35 template <typename InT, typename CallableT>
36 void ForEach(InT&& Input, CallableT Callable)
37 {
38 for (auto& Value : Input)
39 {
40 Invoke(Callable, Value);
41 }
42 }
43}
AUTORTFM_INFER UE_FORCEINLINE_HINT constexpr auto Invoke(FuncType &&Func, ArgTypes &&... Args) -> decltype(((FuncType &&) Func)((ArgTypes &&) Args...))
Definition Invoke.h:44
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
Definition ParallelSort.h:13
void ForEachIf(InT &&Input, PredicateT Predicate, CallableT Callable)
Definition ForEach.h:18
void ForEach(InT &&Input, CallableT Callable)
Definition ForEach.h:36