$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Vinnie Falco (vinnie.falco_at_[hidden])
Date: 2024-12-06 15:44:38
On Thu, Dec 5, 2024 at 12:06â¯PM Vinnie Falco <vinnie.falco_at_[hidden]> wrote:
> ...Instead of writing:
>
> h.update( span );
>
> You instead write:
>
> boost::hash2::update( h, span );
>
Anyway it looks like this wasn't clear so I guess I'll try again and be
even more explicit. Currently, the hash algorithm provides the following
member function for sending a contiguous range of binary data:
void update( void const*, std::size_t );
The combination of pointer and size passed as individual arguments is
triggering to certain folks, who instead prefer the following, or some
variation of it (for example, using uint8_t instead of byte)
void update( std::span< std::byte const > );
This is disfavored by the library author (and myself) for reasons already
posted to the mailing list which I will not repeat. Yet an argument can be
made that the use of a span could be favorable to tooling which performs
buffer safety analysis. Thus I propose to add the following additional free
function. Doing so allows authors of hash functions to call the free
function with a span instead of the update member function which accepts a
pointer and size, without burdening the authors of hash algorithms:
namespace boost::hash2 {
template< typename Hasher >
void update( Hasher& h, std::span< std::byte const > s ) {
h.update( s.data(), s.size() );
}
}
I have to stress that this is not the same as the hash_append function
which by coincidence has an identical signature (and different
implementation). This is the alternative to: 1. changing the signature of
update in the Hasher concept, or 2. adding an overload of update to the
Hasher concept (both of these are disfavored for reasons already given).
Thanks