This improves our Span class by making it closer to the C++20 std::span
one:
Support conversion between compatible Spans (e.g.(done in #18591)Span<char>
toSpan<const char>
).- Make the size type
std::size_t
rather thanstd::ptrdiff_t
(the C++20 one underwent the same change). - Support construction of Spans directly from arrays,
std::string
s,std::array
s,std::vector
s,prevector
s, … (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.