Page MenuHomePhabricator

Span improvements
ClosedPublic

Authored by Fabien on Feb 1 2021, 11:01.

Details

Reviewers
majcosta
Group Reviewers
Restricted Project
Commits
rABC6588bd8ef048: 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>

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Fabien requested review of this revision.Feb 1 2021, 11:01
This revision is now accepted and ready to land.Feb 1 2021, 18:28
This revision was automatically updated to reflect the committed changes.