For checking if it's a managed type you should use the IsManagedType
intrinsic.
You could also use it to implement the System.Move() for non-managed types.
The compiler only generates the appropriate code:
If IsManagedType(T) then
// for loop
else
// move
Best Regards
Nico
Bart via fpc-pasca
On Sat, Jan 9, 2021 at 8:14 PM Yuriy Sydorov via fpc-pascal
wrote:
> > So, I'll use a for loop to copy the data.
> >
> > I assume that doing Arr[Index] := Default(T) will also finalize the
> > element if that element ismanaged?
>
> For class object instances call Arr[Index].Free, for other manage
Op 2021-01-09 om 20:12 schreef Yuriy Sydorov via fpc-pascal:
So, if I move Arr[3] to Arr[1], I first have to finilize/free Arr[1].
After that move the bytes in Arr[3] are exactly the same as in Arr[1]
(by definition of how move works) AFAIU.
Is that a problem with refcounts, because they would
On 09.01.2021 19:23, Bart via fpc-pascal wrote:
On Sat, Jan 9, 2021 at 5:12 PM Yuriy Sydorov via fpc-pascal
wrote:
2. Is it OK if the elements of the array are (or contain) managed types?
You need to manually finalize/free elements which are overwritten before
calling Move.
So, if I move A
On Sat, Jan 9, 2021 at 5:12 PM Yuriy Sydorov via fpc-pascal
wrote:
> > 2. Is it OK if the elements of the array are (or contain) managed types?
>
> You need to manually finalize/free elements which are overwritten before
> calling Move.
So, if I move Arr[3] to Arr[1], I first have to finilize/fr
On 09.01.2021 17:28, Bart via fpc-pascal wrote:
This may be a silly question.
I use System.Move() to move items in a dynamic array, like
Move(FData[0], FData[OldEnd], FStart*SizeOf(T));
Where T is the type of the elements in the array.
This seems to work as expected.
I have some questions tho
Hi,
This may be a silly question.
I use System.Move() to move items in a dynamic array, like
Move(FData[0], FData[OldEnd], FStart*SizeOf(T));
Where T is the type of the elements in the array.
This seems to work as expected.
I have some questions though:
1. Does this depend on the alignment of