strange behavior in opApply
    BCS 
    ao at pathlink.com
       
    Sat Jan 27 10:47:01 PST 2007
    
    
  
I think this is a bug. I am not sure, but it is really annoying.
The following code fails to compile:
struct Foo
{
  int opApply(int delegate(in int) dg)
  {
    for(int i = 0; i< 10; i++)
      if(int ret = dg(i>>2))
        return ret;
    return 0;
  }
}
void main()
{
  Foo f;
  int j=0;
  foreach(int i; f)
  {
    j+=i;
  }
}
The foreach body is turned into a delegate taking (inout int), but it is 
not marked as inout! I have a case where I'm trying to use opApply where 
it can't be inout. 
Is this a bug?
    
    
More information about the Digitalmars-d-bugs
mailing list