Bug 4174 – Template interface functions not allowed, making operator overloads difficult

Status
RESOLVED
Resolution
FIXED
Severity
blocker
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2010-05-10T14:35:00Z
Last change time
2012-04-27T19:33:15Z
Keywords
pull, rejects-valid
Assigned to
yebblies
Creator
schveiguy

Comments

Comment #0 by schveiguy — 2010-05-10T14:35:10Z
Comment #1 by schveiguy — 2010-05-10T14:41:26Z
Sorry, enter key added the issue when I was typing the summary. Operator overloads require template functions, yet this doesn't work: interface I { I addAssign(I other); I opOpAssign(string op)(I other) if (op == "+=") { return this.addAssign(other); } } void foo(I i) { i += i; } error message: testinterface.d(4): Error: function testinterface.I.opOpAssign!("+=").opOpAssign template member functions are not allowed in interface I testinterface.d(12): Error: template instance testinterface.I.opOpAssign!("+=") error instantiating How shall I implement operators for interfaces?
Comment #2 by andrei — 2010-12-29T12:37:55Z
That should be op == "+". With that change I am getting the same error message. Assigning to Walter to expedite review.
Comment #3 by schveiguy — 2010-12-29T12:40:08Z
Yes, I think back in May, you needed "+=".
Comment #4 by yebblies — 2011-06-16T00:02:54Z
Comment #5 by alex — 2012-01-06T07:24:17Z
Any news on this? This is still very much a blocker for many designs.
Comment #6 by yebblies — 2012-04-04T17:44:34Z
*** Issue 7816 has been marked as a duplicate of this issue. ***
Comment #7 by github-bugzilla — 2012-04-27T18:37:45Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/bb9200a4f80c912a4b9e4c4649307d86edb0624c Issue 4174 - Template interface functions not allowed, making operator overloads difficult The lifting restriction banning final and static members in interfaces should also apply to template functions. https://github.com/D-Programming-Language/dmd/commit/f1f09dd8ef3710e631d387268a5cf03507ccf99b Merge pull request #131 from yebblies/issue4174 Issue 4174 - Template interface functions not allowed, making operator overloads difficult