[libc][CPP] Align span copy and conversion with std::span (#220619)
Bring cpp::span copy and converting operations in line with C++20
std::span ([span.overview], [span.cons]):
* Add defaulted copy assignment operator: C++20 std::span declares
constexpr span& operator=(const span&) noexcept = default; Providing an
explicit defaulted copy assignment operator matches std::span and avoids
-Wdeprecated-copy-with-dtor warnings in consuming code when
copy-assigning spans.
* Take const span<U>& in converting constructor and operator=: C++20
[span.cons] specifies converting construction from const span&.
Previously taking span<U>& prevented converting from const spans and
binding to rvalue temporaries (such as s = s.subspan(1)).
* Update span.h and span_test.cpp headers to standard LLVM style.
* Add unit tests for copy assignment, rvalue temporaries, and converting
assignment.
Assisted-by: Automated tooling, human reviewed.
GitOrigin-RevId: 6eb78d3be1ac2f5163fd8a21e19379c4b639d782
2 files changed