Bug 3988 – Provide canonical example for operator overloading

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dlang.org
Product
D
Version
D2
Platform
All
OS
All
Creation time
2010-03-19T23:19:00Z
Last change time
2014-02-15T02:45:44Z
Keywords
spec
Assigned to
nobody
Creator
jlquinn

Comments

Comment #0 by jlquinn — 2010-03-19T23:19:43Z
At first glance, the new operator overloading syntax looks cumbersome by comparison to C++. Adding the following example to the D docs would make it clear what the advantage of the new syntax is, as well as not requiring people to reinvent it repeatedly: http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=101636 2. Use one mixin expression: T opBinary(string op)(T rhs) { return mixin("data "~op~" rhs.data"); }
Comment #1 by github-bugzilla — 2012-01-23T17:36:39Z