HomePhabricator

Span improvements

Description

Span improvements

Summary:

This improves our Span class by making it closer to the C++20 std::span
one:
 - Make the size type std::size_t rather than std::ptrdiff_t (the C++20
one underwent the same change).
 - Support construction of Spans directly from arrays, std::strings,
std::arrays, std::vectors, prevectors, ... (for all but arrays, this
only works for const containers to prevent surprises).

And then make use of those improvements in various call sites.

I realize the template magic used looks scary, but it's only needed to
make overload resultion make the right choices. Note that the operations
done on values are all extremely simple: no casts, explicit conversions,
or warning-silencing constructions. That should hopefully make it
simpler to review.

Backport of core PR18468.

Test Plan:

ninja all check-all

ninja bitcoin-fuzzers
./test/fuzz/test_runner.py <path_to_corpus>

Reviewers: #bitcoin_abc, majcosta

Reviewed By: #bitcoin_abc, majcosta

Differential Revision: https://reviews.bitcoinabc.org/D9121

Details

Provenance
Pieter Wuille <pieter.wuille@gmail.com>Authored on Mar 29 2020, 23:31
FabienCommitted on Feb 2 2021, 07:26
FabienPushed on Feb 2 2021, 07:28
Reviewer
Restricted Project
Differential Revision
D9121: Span improvements
Parents
rABC6705b69d8931: [Web - New] Adding cashtab-components source
Branches
Unknown
Tags
Unknown

Event Timeline

Fabien committed rABC6588bd8ef048: Span improvements (authored by Pieter Wuille <pieter.wuille@gmail.com>).Feb 2 2021, 07:26