The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My work

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,311 other followers

Use operator overloading for classes with non-ARC compiler · GitHub

Posted by jpluimers on 2017/11/23

[WayBackUse 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:

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: [WayBackOperator Overloading (Delphi) – RAD Studio

Oh, this thread needs some change now: [WayBackList of Delphi language features and version in which they were introduced/deprecated – Stack Overflow

–jeroen

One Response to “Use operator overloading for classes with non-ARC compiler · GitHub”

  1. rvelthuis said

    It makes sense for operators that do not return an instance of the same class, but e.g. a Boolean, e.g. operators like in, comparison operators, etc. They do not bear the risk of memory leaks.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: