hash/crc: document template parameters

This commit is contained in:
Danny Robson 2017-02-20 18:01:40 +11:00
parent bec24535fc
commit f4093cb3d5
2 changed files with 13 additions and 0 deletions

View File

@ -173,6 +173,9 @@ util::hash::crc<
DigestT,Generator,Initial,Final,ReflectIn,ReflectOut
>::table (void)
{
// We want to use a std::array here for a (slight) safety advantage, but
// it means that we have to use calls to array::data instead of operator[]
// to retain constexpr.
std::array<digest_t,256> values {};
if (ReflectIn) {

View File

@ -29,6 +29,16 @@ namespace util { namespace hash {
//
// Adapted from the PNG specification (ISO/IEC 15948:2003), appendix D and
// the public domain implementation of Ross Williams.
//
// Generator: the polynomial, with the leading (ie, 32nd) high bit truncated.
// Initial: value used to initialise the digest
// Final: value to xor against the digest at finish time
// ReflectIn: whether to reverse the bits of each data byte
// ReflectOut: whether to reverse the bits of the digest at finish time
//
// Note that reflection isn't necessarily explicitly performed at update
// time. Instead we construct the lookup table appropriately to directly
// use the data values directly.
template <
typename DigestT,
DigestT Generator,