Wich: opIndex overloading by return type

Robert M. Münch robert.muench at saphirion.com
Sun Apr 19 15:53:43 UTC 2020


Wouldn't it make a lot of sense to allow different opIndex 
implementations based on return type?

class myC {
	myT1 opIndex(int x)
	myT2 opIndex(int x)
}

Depending on the types involved myC[1] woudl return myT1 or myT2. 
Use-case: I have a geomentry object and in one case I get x0,y0,x1,y1 
and in the other case x,y,w,h

IMO that would make a lot of sense.

-- 
Robert M. Münch
http://www.saphirion.com
smarter | better | faster



More information about the Digitalmars-d-learn mailing list