Add Exchange<T> that works like std::exchange in C++.

(cherry picked from commit 05b7ebd34e)
This commit is contained in:
Rika Ichinose 2023-11-21 04:34:16 +03:00 committed by marcoonthegit
parent 587c1df60e
commit 52d7e9b49f
2 changed files with 7 additions and 0 deletions

View File

@ -287,6 +287,7 @@ type
{$IFNDEF VER3_0}
generic function IfThen<T>(val:boolean;const iftrue:T; const iffalse:T) :T; inline; overload;
generic function Exchange<T>(var target:T; const newvalue:T) :T; inline;
{$ENDIF}
Var

View File

@ -872,6 +872,12 @@ begin
else
Result:=ifFalse;
end;
generic function Exchange<T>(var target:T; const newvalue:T) :T;
begin
Result := target;
target := newvalue;
end;
{$ENDIF}
Function ArrayOfConstToStrArray(Args: array of const) : TUTF8StringDynArray;