casting with preserving attributes
bearophile
bearophileHUGS at lycos.com
Wed May 22 06:01:25 PDT 2013
Jack Applegame:
> I found awkward solution:
>
> template ByteType(alias t) {
> alias typeof(t) T;
> static if(is(ElementType!T == const)) alias const(byte)[]
> ByteType;
> else static if(is(ElementType!T == immutable)) alias
> immutable(byte)[] ByteType;
> else alias byte[] ByteType;
> }
I think that's essentially the right solution. I suggest to
generalize it a bit, removing the byte from its insides, and
making it a template argument. I think "shared" is missing.
Bye,
bearophile
More information about the Digitalmars-d-learn
mailing list