Hi all

Hi all,
I Have two records i want to compare their references (something similar to .NET referenceequals), my approach seems to fail, ( I get access violations)
my function below tries to convert my record to an object so that I can use TObject 'equals' helper to compare their object Instances.

class function TIntX.MakeTIntXRecordAnObject(Const anInstance: TIntX): TObject;
begin
  Move(anInstance, result, SizeOf(anInstance));
end;

hovering over 'result' in the debugger after executing the move command indicates that 'result' is empty.

also tried casting " result := TObject(anInstance);" but it did not compile with error saying invalid typecast.
please how do I do this, to be compatible with both 32bit and 64bits.
Thanks.

Comments

  1. @ Chris Rolliston, I guess I will roll out my own type specific comparison

    thanks

    ReplyDelete
  2. Or write an IsEqualTo(const other): boolean. If you are managing lots of different records i guess RTTI could help. Steep curve but nice when it's finished.

    ReplyDelete

Post a Comment