multiple opApply functions?

Daniel Keep daniel.keep.lists at gmail.com
Mon May 21 02:36:12 PDT 2007



Jason House wrote:
> Is it possible to have multiple opApply calls for a single class?  The
> following code almost compiles. It appears gdc 0.23 (implementing dmd
> 1.007) tries to match against the first opApply instead of finding the
> correct match (the 2nd opApply).
> 
> The compiler knows the first one is a bad match, gives an error, and
> exits.  How do I overcome this?
> 
> interface X(T,P){
>   int opApply(int delegate(P));
>   int opApply(int delegate(T));
>   int opApply(int delegate(P,T));
> }
> 
> class Y(T,P) : public X(T,P){
>   ...
> }
> 
> int main(){
>   Y y = new Y!(int,float)(...);
>   foreach(int x; y){
>     ...
>   }
> }

Random thought: aren't those delegates supposed to be "int delegate(ref
P)"?  I'm pretty sure DMD is touchy about that...

-- 
int getRandomNumber()
{
    return 4; // chosen by fair dice roll.
              // guaranteed to be random.
}

http://xkcd.com/

v2sw5+8Yhw5ln4+5pr6OFPma8u6+7Lw4Tm6+7l6+7D
i28a2Xs3MSr2e4/6+7t4TNSMb6HTOp5en5g6RAHCP  http://hackerkey.com/


More information about the Digitalmars-d-learn mailing list