The OpenD Programming Language

hasPeek

Used to check if a digest supports the peek method. Peek has exactly the same function signatures as finish, but it doesn't reset the digest's internal state.

Note:

  • This is very useful as a template constraint (see examples)
  • This also checks if T passes isDigest
template hasPeek (
T
) {
enum bool hasPeek;
}

Examples

import std.digest.crc, std.digest.md;
assert(!hasPeek!(MD5));
assert(hasPeek!CRC32);
import std.digest.crc;
void myFunction(T)()
if (hasPeek!T)
{
    T dig;
    dig.start();
    auto result = dig.peek();
}
myFunction!CRC32();

Meta