The review of std.hash package

Walter Bright newshound2 at digitalmars.com
Wed Aug 8 11:47:38 PDT 2012


On 8/8/2012 9:47 AM, Johannes Pfau wrote:
> 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();
> }
> ----

The finish() should be implicit when the range ends.

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

I don't know what you mean, it takes a range, not a void[][] as input.




More information about the Digitalmars-d mailing list