[llvm] [NFC][ADT] Add reverse iterators and `value_type` to StringRef (PR #105579)

Rahul Joshi via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 22 05:27:07 PDT 2024


================
@@ -72,9 +72,18 @@ TEST(StringRefTest, EmptyInitializerList) {
 
 TEST(StringRefTest, Iteration) {
   StringRef S("hello");
-  const char *p = "hello";
-  for (const char *it = S.begin(), *ie = S.end(); it != ie; ++it, ++p)
-    EXPECT_EQ(*it, *p);
+  constexpr StringLiteral CS("hello");
+
+  // Note: Cannot use literal strings in equal() as iteration over a literal
+  // string includes the null terminator.
+  constexpr std::string_view RefFwd("hello");
+  constexpr std::string_view RefRev("olleh");
----------------
jurahul wrote:

Done.

https://github.com/llvm/llvm-project/pull/105579


More information about the llvm-commits mailing list