scripted-diff: Use std::span over Span

-BEGIN VERIFY SCRIPT-

 ren() { sed -i "s!\<$1\>!$2!g" $( git grep -l "$1" -- "./src" ":(exclude)src/span.h" ":(exclude)src/leveldb/db/log_test.cc" ) ; }

 ren Span            std::span
 ren AsBytes         std::as_bytes
 ren AsWritableBytes std::as_writable_bytes

 sed -i 's!SpanPopBack(Span!SpanPopBack(std::span!g' ./src/span.h

-END VERIFY SCRIPT-
This commit is contained in:
MarcoFalke
2024-12-17 16:25:22 +01:00
parent fadccc26c0
commit fade0b5e5e
120 changed files with 543 additions and 543 deletions

View File

@@ -18,7 +18,7 @@ AutoFile::AutoFile(std::FILE* file, std::vector<std::byte> data_xor)
}
}
std::size_t AutoFile::detail_fread(Span<std::byte> dst)
std::size_t AutoFile::detail_fread(std::span<std::byte> dst)
{
if (!m_file) throw std::ios_base::failure("AutoFile::read: file handle is nullptr");
size_t ret = std::fread(dst.data(), 1, dst.size(), m_file);
@@ -57,7 +57,7 @@ int64_t AutoFile::tell()
return *m_position;
}
void AutoFile::read(Span<std::byte> dst)
void AutoFile::read(std::span<std::byte> dst)
{
if (detail_fread(dst) != dst.size()) {
throw std::ios_base::failure(feof() ? "AutoFile::read: end of file" : "AutoFile::read: fread failed");
@@ -78,7 +78,7 @@ void AutoFile::ignore(size_t nSize)
}
}
void AutoFile::write(Span<const std::byte> src)
void AutoFile::write(std::span<const std::byte> src)
{
if (!m_file) throw std::ios_base::failure("AutoFile::write: file handle is nullptr");
if (m_xor.empty()) {
@@ -90,7 +90,7 @@ void AutoFile::write(Span<const std::byte> src)
if (!m_position.has_value()) throw std::ios_base::failure("AutoFile::write: position unknown");
std::array<std::byte, 4096> buf;
while (src.size() > 0) {
auto buf_now{Span{buf}.first(std::min<size_t>(src.size(), buf.size()))};
auto buf_now{std::span{buf}.first(std::min<size_t>(src.size(), buf.size()))};
std::copy(src.begin(), src.begin() + buf_now.size(), buf_now.begin());
util::Xor(buf_now, m_xor, *m_position);
if (std::fwrite(buf_now.data(), 1, buf_now.size(), m_file) != buf_now.size()) {