[WayBack] Use operator overloading for classes with non-ARC compiler · GitHub
The trick: do not use class operator
but use class function &&op_
with the special operator name in the table referenced below. Just follow the bulleted example links to get an idea.
Bonus: it works on class helper
constructs as well.
Officially this unsupported and with the non-ARC compiler you will have a risk of memory leaks.
But it’s so much fun as these links prove:
- [WayBack] 『*[Delphi]』の検索結果 – 全力わはー (in Japanese; from the guy that discovered it)
- and blogged about it: [WayBack] Use operator overloading for classes with non-ARC compiler – Zenryokuwawa
- [WayBack] Sobrecarga de operadores de clase – Foros Club Delphi (in Spanish; from the guy that dug deeper)
- TObjectHelper example – [WayBack] OpOverloadWithGenerics.pas · GitHub
- TStringListEx and TPointHelper example – [WayBack] Use operator overloading for classes with non-ARC compiler · GitHub
The usual operator gotchas apply here as well: Delphi operator overloading: table of operators, names, and some notes on usage and ‘glitches’.
The operators you could try: [WayBack] Operator Overloading (Delphi) – RAD Studio
Oh, this thread needs some change now: [WayBack] List of Delphi language features and version in which they were introduced/deprecated – Stack Overflow
–jeroen