www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - const and mutable opApply's

reply Oleg B <code.viator gmail.com> writes:
Hello

struct WTable
{
...
     private enum opApply_body = q{
         if( smt )
         {
             foreach( f; 0 .. size-1 )
                 foreach( t; f+1 .. size )
                     if( auto r = dlg(f,t,data[getIndex(f,t)]) ) 
return r;
         }
         else
         {
             foreach( f; 0 .. size )
                 foreach( t; 0 .. size )
                 {
                     if( f == t ) continue;
                     if( auto r = dlg(f,t,data[getIndex(f,t)]) )
                         return r;
                 }
         }
         return 0;
     };

     int opApply( int delegate(size_t,size_t,T val) dlg ) const { 
mixin( opApply_body ); }
     int opApply( int delegate(size_t,size_t,ref T val) dlg ) { 
mixin( opApply_body ); }
}

How I can rewrite this code without mixin's and with one (maybe 
inout) opApply?
Jun 19 2016
parent Steven Schveighoffer <schveiguy yahoo.com> writes:
On 6/19/16 6:17 PM, Oleg B wrote:
 Hello
...
 How I can rewrite this code without mixin's and with one (maybe inout)
 opApply?
Someone just asked a similar question about this: https://forum.dlang.org/post/nk90v2$1fr3$1 digitalmars.com -Steve
Jun 20 2016