|
Boost : |
From: Alexander Grund (alexander.grund_at_[hidden])
Date: 2024-12-06 11:56:04
> If i understand correctly:
>
> std::span<char> v("123", 3)
>
> hash_append(h, v); // hash "123" + the size 3, as v is a container
> h.update(v); // hash only "123".
>
> Or did i miss something?
I think this is actually an important question: How to (conveniently)
hash only a range? I.e. with the library, not the hasher.
As in the example there might be use cases to calculate e.g. the
checksum of a file using the hash algorithm as a template.
For this the size of the data/file must not be included in the hash.
I've seen `hash_append_range` which could be used but needs to get the
begin/end manually.
I think a 3 parameter form `hash_append_range(Hash&, Flavor&, Range)`
would be a good addition to support the above use case without having to
call the hasher directly.
I.e. to provide a similar interface/abstraction to `hash_append`
Maybe name it `hash_append_range_without_size` to discourage people from
using it without knowing the caveats (multiple ranges, empty ranges, ...)
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk