pw_span: Move pw_string, pw_unit_test to std::span
- Update pw_string and the test framework to std::span.
- Have pw_string pass std::span by value, for consistency with other
uses in Pigweed.
- Recommend using template specializations instead of overloads for
custom ToString implementations. Template specializations are
preferred because the main ToString definition is a template.
Change-Id: Ib67c6bce1752c4a90e2138bdb1f20c6671f55d50
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/12841
Reviewed-by: Keir Mierle <keir@google.com>
Commit-Queue: Wyatt Hepler <hepler@google.com>
diff --git a/pw_string/format_test.cc b/pw_string/format_test.cc
index ad7e39e..dfaac7b 100644
--- a/pw_string/format_test.cc
+++ b/pw_string/format_test.cc
@@ -15,9 +15,9 @@
#include "pw_string/format.h"
#include <cstdarg>
+#include <span>
#include "gtest/gtest.h"
-#include "pw_span/span.h"
namespace pw::string {
namespace {
@@ -41,7 +41,7 @@
}
TEST(Format, EmptyBuffer_ReturnsResourceExhausted) {
- auto result = Format(span<char>(), "?");
+ auto result = Format(std::span<char>(), "?");
EXPECT_EQ(Status::RESOURCE_EXHAUSTED, result.status());
EXPECT_EQ(0u, result.size());
@@ -65,7 +65,9 @@
EXPECT_STREQ("2big", buffer);
}
-StatusWithSize CallFormatWithVaList(span<char> buffer, const char* fmt, ...) {
+StatusWithSize CallFormatWithVaList(std::span<char> buffer,
+ const char* fmt,
+ ...) {
va_list args;
va_start(args, fmt);