pw_span: Switch from pw::span to std::span

Replace pw::span with std::span and "pw_span/span.h" with <span>
throughout the codebase.

Change-Id: Ib1fa873168b6093794e861611d750fcad6285d6c
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/12801
Commit-Queue: Wyatt Hepler <hepler@google.com>
Reviewed-by: Rob Mohr <mohrr@google.com>
Reviewed-by: Keir Mierle <keir@google.com>
diff --git a/pw_kvs/key_value_store.cc b/pw_kvs/key_value_store.cc
index 68a8412..a106592 100644
--- a/pw_kvs/key_value_store.cc
+++ b/pw_kvs/key_value_store.cc
@@ -39,7 +39,7 @@
 }  // namespace
 
 KeyValueStore::KeyValueStore(FlashPartition* partition,
-                             span<const EntryFormat> formats,
+                             std::span<const EntryFormat> formats,
                              const Options& options,
                              size_t redundancy,
                              Vector<SectorDescriptor>& sector_descriptor_list,
@@ -385,7 +385,7 @@
        address += Entry::kMinAlignmentBytes) {
     uint32_t magic;
     StatusWithSize read_result =
-        partition_.Read(address, as_writable_bytes(span(&magic, 1)));
+        partition_.Read(address, std::as_writable_bytes(std::span(&magic, 1)));
     if (!read_result.ok()) {
       continue;
     }
@@ -400,7 +400,7 @@
 }
 
 StatusWithSize KeyValueStore::Get(string_view key,
-                                  span<byte> value_buffer,
+                                  std::span<byte> value_buffer,
                                   size_t offset_bytes) const {
   TRY_WITH_SIZE(CheckReadOperation(key));
 
@@ -410,7 +410,7 @@
   return Get(key, metadata, value_buffer, offset_bytes);
 }
 
-Status KeyValueStore::PutBytes(string_view key, span<const byte> value) {
+Status KeyValueStore::PutBytes(string_view key, std::span<const byte> value) {
   TRY(CheckWriteOperation(key));
   DBG("Writing key/value; key length=%u, value length=%u",
       unsigned(key.size()),
@@ -537,7 +537,7 @@
 
 StatusWithSize KeyValueStore::Get(string_view key,
                                   const EntryMetadata& metadata,
-                                  span<std::byte> value_buffer,
+                                  std::span<std::byte> value_buffer,
                                   size_t offset_bytes) const {
   Entry entry;
 
@@ -584,7 +584,7 @@
   }
 
   StatusWithSize result =
-      Get(key, metadata, span(static_cast<byte*>(value), size_bytes), 0);
+      Get(key, metadata, std::span(static_cast<byte*>(value), size_bytes), 0);
 
   return result.status();
 }
@@ -624,7 +624,7 @@
 Status KeyValueStore::WriteEntryForExistingKey(EntryMetadata& metadata,
                                                EntryState new_state,
                                                string_view key,
-                                               span<const byte> value) {
+                                               std::span<const byte> value) {
   // Read the original entry to get the size for sector accounting purposes.
   Entry entry;
   TRY(ReadEntry(metadata, entry));
@@ -633,7 +633,7 @@
 }
 
 Status KeyValueStore::WriteEntryForNewKey(string_view key,
-                                          span<const byte> value) {
+                                          std::span<const byte> value) {
   if (entry_cache_.full()) {
     WRN("KVS full: trying to store a new entry, but can't. Have %u entries",
         unsigned(entry_cache_.total_entries()));
@@ -644,7 +644,7 @@
 }
 
 Status KeyValueStore::WriteEntry(string_view key,
-                                 span<const byte> value,
+                                 std::span<const byte> value,
                                  EntryState new_state,
                                  EntryMetadata* prior_metadata,
                                  const Entry* prior_entry) {
@@ -721,7 +721,7 @@
                                            size_t write_size) {
   for (size_t i = 0; i < redundancy(); i++) {
     SectorDescriptor* sector;
-    TRY(GetSectorForWrite(&sector, write_size, span(write_addresses, i)));
+    TRY(GetSectorForWrite(&sector, write_size, std::span(write_addresses, i)));
     write_addresses[i] = sectors_.NextWritableAddress(*sector);
 
     DBG("Found space for entry in sector %u at address %u",
@@ -739,7 +739,7 @@
 // RESOURCE_EXHAUSTED: No sector available with the needed space.
 Status KeyValueStore::GetSectorForWrite(SectorDescriptor** sector,
                                         size_t entry_size,
-                                        span<const Address> reserved) {
+                                        std::span<const Address> reserved) {
   Status result = sectors_.FindSpace(sector, entry_size, reserved);
 
   size_t gc_sector_count = 0;
@@ -793,7 +793,7 @@
 
 Status KeyValueStore::AppendEntry(const Entry& entry,
                                   string_view key,
-                                  span<const byte> value) {
+                                  std::span<const byte> value) {
   const StatusWithSize result = entry.Write(key, value);
 
   SectorDescriptor& sector = sectors_.FromAddress(entry.address());
@@ -839,9 +839,10 @@
   return result;
 }
 
-Status KeyValueStore::RelocateEntry(const EntryMetadata& metadata,
-                                    KeyValueStore::Address& address,
-                                    span<const Address> reserved_addresses) {
+Status KeyValueStore::RelocateEntry(
+    const EntryMetadata& metadata,
+    KeyValueStore::Address& address,
+    std::span<const Address> reserved_addresses) {
   Entry entry;
   TRY(ReadEntry(metadata, entry));
 
@@ -937,10 +938,11 @@
   if (error_detected_ && options_.recovery != ErrorRecovery::kManual) {
     TRY(Repair());
   }
-  return GarbageCollect(span<const Address>());
+  return GarbageCollect(std::span<const Address>());
 }
 
-Status KeyValueStore::GarbageCollect(span<const Address> reserved_addresses) {
+Status KeyValueStore::GarbageCollect(
+    std::span<const Address> reserved_addresses) {
   DBG("Garbage Collect a single sector");
   for (Address address : reserved_addresses) {
     DBG("   Avoid address %u", unsigned(address));
@@ -962,7 +964,7 @@
 Status KeyValueStore::RelocateKeyAddressesInSector(
     SectorDescriptor& sector_to_gc,
     const EntryMetadata& metadata,
-    span<const Address> reserved_addresses) {
+    std::span<const Address> reserved_addresses) {
   for (FlashPartition::Address& address : metadata.addresses()) {
     if (sectors_.AddressInSector(sector_to_gc, address)) {
       DBG("  Relocate entry for Key 0x%08" PRIx32 ", sector %u",
@@ -976,7 +978,8 @@
 };
 
 Status KeyValueStore::GarbageCollectSector(
-    SectorDescriptor& sector_to_gc, span<const Address> reserved_addresses) {
+    SectorDescriptor& sector_to_gc,
+    std::span<const Address> reserved_addresses) {
   DBG("  Garbage Collect sector %u", sectors_.Index(sector_to_gc));
   // Step 1: Move any valid entries in the GC sector to other sectors
   if (sector_to_gc.valid_bytes() != 0) {
@@ -1121,7 +1124,7 @@
   }
   if (empty_sector_found == false) {
     DBG("   No empty sector found, attempting to GC a free sector");
-    Status sector_status = GarbageCollect(span<const Address, 0>());
+    Status sector_status = GarbageCollect(std::span<const Address, 0>());
     if (repair_status.ok() && !sector_status.ok()) {
       DBG("   Unable to free an empty sector");
       repair_status = sector_status;
@@ -1207,7 +1210,7 @@
 
 KeyValueStore::Entry KeyValueStore::CreateEntry(Address address,
                                                 string_view key,
-                                                span<const byte> value,
+                                                std::span<const byte> value,
                                                 EntryState state) {
   // Always bump the transaction ID when creating a new entry.
   //