various questions
    Kagamin 
    spam at here.lot
       
    Thu Jul 29 10:22:37 PDT 2010
    
    
  
Kagamin Wrote:
> Jason Spencer Wrote:
> 
> > If I want to avoid the copy, am I relegated back
> > to pointers?
> 
or something like this
struct ReferenceArray!(ArrayType)
{
  ArrayType* back;
  this(byte[] data)
  {
    assert(data.length==ArrayType.sizeof);
    back = cast(ArrayType*)data.ptr;
  }
  //will it be inlined?
  auto opIndex(int column, int row)
  {
    return (*back)[row][column];
  }
}
byte[] data = getData();
ReferenceArray!(float[100][100]) matrix = data;
writeln(matrix[1][2]);
    
    
More information about the Digitalmars-d-learn
mailing list