The review of std.hash package

Johannes Pfau nospam at example.com
Wed Aug 8 09:47:26 PDT 2012


Am Wed, 8 Aug 2012 17:50:33 +0200
schrieb Johannes Pfau <nospam at example.com>:

> However, I do agree digest!Hash, md5Of, sha1Of should have an
> additional overload which takes a InputRange. It would be implemented
> with copy and be a nice convenience function.

I implemented the function, it's actually quite simple:
----
digestType!Hash digestRange(Hash, Range)(Range data) if(isDigest!Hash &&
    isInputRange!Range && __traits(compiles,
    digest!Hash(ElementType!(Range).init)))
{
    Hash hash;
    hash.start();
    copy(data, hash);
    return hash.finish();
}
----

but I don't know how make it an overload. See thread "overloading a
function taking a void[][]" in D.learn for details.


More information about the Digitalmars-d mailing list