Also note that if you use Default multiple times in the same function, it will only create the temporary object once and re-use it every time. I think a better optimization would be even to create that temporary object globally rather than in the function that calls ist, especially if it has initialization code.
That's what
main does since 2023.
Warfley...?
{$ifdef fpc}{$mode delphi}{$endif}
uses rtti; // <<----
procedure Init<T>(var A:T) inline;
Begin
if ismanaged(A) then // or T
begin
Finalize(A);
Initialize(A);
end
else
FillByte(A,SizeOf(T),0);
end;
begin
end.
Not an intrinsic and possibly a bit runtime focussed. But the functionality is there. Also in 3.2.X
And it seems both of you are not aware of the existence of
IsManagedType which is an intrinsic and exists since
3.2.0... 🙄