From 561e149058677b8e96fafa42af91718d3617a0fe Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Mon, 27 Jan 2020 00:03:01 -0500 Subject: [PATCH] Better templates the CRC generator. --- Numeric/CRC.hpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/Numeric/CRC.hpp b/Numeric/CRC.hpp index 928db5574..04faf2515 100644 --- a/Numeric/CRC.hpp +++ b/Numeric/CRC.hpp @@ -66,9 +66,23 @@ template &data) { + template T compute_crc(const Collection &data) { + return compute_crc(data.begin(), data.end()); + } + + /*! + A compound for: + + reset() + [add all data from @c begin to @c end] + get_value() + */ + template T compute_crc(Iterator begin, Iterator end) { reset(); - for(const auto &byte: data) add(byte); + while(begin != end) { + add(*begin); + ++begin; + } return get_value(); }