various questions
Kagamin
spam at here.lot
Thu Jul 29 10:14:42 PDT 2010
Jason Spencer Wrote:
> If I want to avoid the copy, am I relegated back
> to pointers?
you can make a thin wrapper that will work as a reference-type static array
struct ReferenceArray!(ElementType, int columns, int rows)
{
ElementType[columns][rows]* back;
this(byte[] data)
{
assert(data.length==ElementType.sizeof*columns*rows);
back = cast(ElementType[columns][rows]*)data.ptr;
}
//will it be inlined?
ElementType opIndex(int column, int row)
{
return (*back)[row][column];
}
}
More information about the Digitalmars-d-learn
mailing list