casting with preserving attributes

Jack Applegame japplegame at gmail.com
Wed May 22 04:55:37 PDT 2013


Hello.

I need a template for casting arrays to another type without 
changing const and immutable attributes:

template ByteType(T) {
   // some magic
}

const(int)[] ca;
immutable(short)[] is;
long[] ml;

static assert(is(ByteType!ca == const(byte)[]));
static assert(is(ByteType!is == immutable(byte)[]));
static assert(is(ByteType!ml == byte[]));

What kind of template magic I should use?


More information about the Digitalmars-d-learn mailing list