cast from void[] to ubyte[] in ctfe
Johannes Pfau
nospam at example.com
Fri Jul 13 02:16:18 PDT 2012
Casting from void[] to ubyte[] is currently not allowed in CTFE. Is
there a special reason for this? I don't see how this cast can be
dangerous?
I need this for a function which accepts any type and passes it's
binary representation to a function only accepting a ubyte[]:
-----------------
digestType!Hash digest(Hash)(scope const(void[])[] data...)
if(isDigest!Hash) {
Hash hash;
hash.start();
foreach(datum; data)
hash.put(cast(const(ubyte[]))datum);
return hash.finish();
}
-----------------
Error: array cast from const(void[]) to const(ubyte[]) is not supported
at compile time
I could templatize digest on the data type but shouldn't there be
a way to do this without the additional template bloat?
More information about the Digitalmars-d-learn
mailing list