Vote for the new std.hash (oops, std.digest)

Johannes Pfau nospam at example.com
Mon Aug 27 04:12:28 PDT 2012


Am Fri, 24 Aug 2012 17:49:00 +0200
schrieb "d_follower" <d_follower at fakemail.com>:

> 
> But I'd like to see at least one algorithm being implemented 
> (e.g. CRC32 which currently works with CTFE) as a proof of 
> concept (and a unit-test).

Proof of concept:
http://dpaste.dzfl.pl/b14e8aad

As you can see the templated digest and toHexString functions already
work fine in CTFE. Please note that it can only work with data which can
be converted to ubyte[] in CTFE (so char[] works, but wchar[] probably
not).

The changes for CRC32 where quite simple, replacing
"nativeToLittleEndian" with version(BigEndian) and bswap and using the
getByte function to convert from uint to ubyte[4].

I won't include this code now though, as the review is almost finished.
I'll post an additional pull request instead. However, I also have to
be sure what getByte does is actually supported and not just some
oversight in CTFE.


More information about the Digitalmars-d mailing list