|
Boost : |
From: Peter Dimov (pdimov_at_[hidden])
Date: 2024-12-04 14:38:20
Claudio DeSouza wrote:
> > So I switched `update` back to void const*. The "type safety" gains
> > aren't worth the substantial decrease in usability.
> >
>
> In my experience, the usability/readability gains are on the side of using span.
> This may involve providing extensions, but at the end of the day you get more
> C++-friendly constructs.
Well... no, they aren't.
Suppose you have the data in `std::vector<unsigned char> v`. With the current
`update` that's
hash.update( v.data(), v.size() );
And if you have the data in `std::string st`, that's
hash.update( st.data(), st.size() );
Now suppose `update` takes `span<unsigned char const>`. For `v`, this is
hash.update( v );
which is nice; but for `st`, that would be (assuming C++17)
hash.update( as_bytes( span{st} ) );
which is not so nice.
In Chromium you have as_byte_span, which does as_bytes(span(x)), so
it'd be better.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk