Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2024-12-05 12:55:10


Alexander Grund wrote:
> But you are currently defining the interface of the hash algorithms:
> constexpr void update( unsigned char const* data, std::size_t n );
> My proposal is to define it as e.g.
> constexpr void update(span<unsigned char const>);

Which span is that, though?

> I.e. to go range-safe from the start.
> That would not depend on the hash library but on the chosen span
> library, which might be more acceptable.
> However in C++11/14 this would require the Boost span, so I guess this
> is also off the table, unless the interface would be required to support
> span-likes
> which could be done by users via templates and not require a specific
> span implementation.

Even if we could assume C++20 and std::span, the interface taking
std::span<unsigned char const> is inferior in usability to the current
approach because it doesn't work well for ranges of `char` or `byte`.

> But even with the current interface of "potentially unsafe" hash
> algorithms the `hash_append` could be written to accept only spans/ranges.

I'm not sure what this means. hash_append already accepts spans and
ranges, and is type safe.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk