Generic operator overloading for immutable types?
    Ali Çehreli via Digitalmars-d-learn 
    digitalmars-d-learn at puremagic.com
       
    Mon Jun 12 13:08:13 PDT 2017
    
    
  
On 06/12/2017 01:03 PM, Gary Willoughby wrote:
 > On Monday, 12 June 2017 at 19:36:52 UTC, H. S. Teoh wrote:
 >>      public inout Rational opBinary(string op)(inout Rational rhs)
 > Quick question about the signature, if I change it to (note the parens):
 >
 >    public inout(Rational) opBinary(string op)(inout(Rational) rhs)
 >
 > It no longer works, why is that?
That's frequently faced issue with D. :) In the first declaration, inout 
applies to the member function. In the second one, it applies only to 
the return type. Walter has his rationale for doing it that way but it's 
confusing.
Ali
    
    
More information about the Digitalmars-d-learn
mailing list