UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
Replace.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "Templates/Invoke.h"
7
8namespace Algo
9{
17 template <typename RangeType, typename ValueType>
18 void Replace(RangeType&& Range, const ValueType& InOld, const ValueType& InNew)
19 {
20 for (auto& Elem : Forward<RangeType>(Range))
21 {
22 if (Elem == InOld)
23 {
24 Elem = InNew;
25 }
26 }
27 }
28
36 template <typename RangeType, typename ValueType, typename PredicateType>
37 void ReplaceIf(RangeType&& Range, PredicateType InPred, const ValueType& InNew)
38 {
39 for (auto& Elem : Forward<RangeType>(Range))
40 {
41 if (Invoke(InPred, Elem))
42 {
43 Elem = InNew;
44 }
45 }
46 }
47}
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 ReplaceIf(RangeType &&Range, PredicateType InPred, const ValueType &InNew)
Definition Replace.h:37