about summary refs log tree commit diff
path: root/absl/strings/str_split.cc
diff options
context:
space:
mode:
authorAbseil Team <absl-team@google.com>2018-08-29T22·09-0700
committerjueminyang <jueminyang@google.com>2018-08-30T14·48-0400
commit0f4bc966754ec6cd28d5f03467d56f1efdc598e3 (patch)
tree8c146475fced5abb51b15e385c1a636216fa1640 /absl/strings/str_split.cc
parent6c7e5ffc43decd92f7bdfc510ad8a245a20b6dea (diff)
Export of internal Abseil changes.
--
ed4be0cb9a708158187a0628c1c2167ae6783274 by Greg Falcon <gfalcon@google.com>:

Refactor a string unit test into a template function for internal purposes.

PiperOrigin-RevId: 210798880

--
e4c734be903ac7b3a88caf4b17909343c283a21a by Abseil Team <absl-team@google.com>:

Add a note that the RFC3339_* format specifiers use %Y, and so
do not produce 4-digit years on output nor require 4-digit years
on input, as a strict reading of RFC3339 might require.

PiperOrigin-RevId: 210785544

--
cfb5e32f9397e49ddb731445a191b36652fe2f6d by Greg Falcon <gfalcon@google.com>:

Refactor a string unit test into a template function for internal purposes.

PiperOrigin-RevId: 210776525

--
105ee700e62869cfda2a37e6f7c2ea483f8fc75e by Xiaoyi Zhang <zhangxy@google.com>:

Correctly define ABSL_HAVE_STD_STRING_VIEW for MSVC 2017. Currently the macro
is not defined even though MSVC 2017 provides `std::string_view`, and this
means both `absl::string_view` and `std::string_view` exist as distinct types.
A bunch of places relying on the false assumption that
`string_view::const_iterator` is `const char*` have to be fixed to build
successfully.

See related github issue https://github.com/abseil/abseil-cpp/issues/161.

PiperOrigin-RevId: 210764947
GitOrigin-RevId: ed4be0cb9a708158187a0628c1c2167ae6783274
Change-Id: I7a9658b3201aa669db9d3d90474feb08072718c7
Diffstat (limited to 'absl/strings/str_split.cc')
-rw-r--r--absl/strings/str_split.cc13
1 files changed, 7 insertions, 6 deletions
diff --git a/absl/strings/str_split.cc b/absl/strings/str_split.cc
index 0207213c26ba..0a68c52d14f1 100644
--- a/absl/strings/str_split.cc
+++ b/absl/strings/str_split.cc
@@ -43,10 +43,11 @@ absl::string_view GenericFind(absl::string_view text,
   if (delimiter.empty() && text.length() > 0) {
     // Special case for empty std::string delimiters: always return a zero-length
     // absl::string_view referring to the item at position 1 past pos.
-    return absl::string_view(text.begin() + pos + 1, 0);
+    return absl::string_view(text.data() + pos + 1, 0);
   }
   size_t found_pos = absl::string_view::npos;
-  absl::string_view found(text.end(), 0);  // By default, not found
+  absl::string_view found(text.data() + text.size(),
+                          0);  // By default, not found
   found_pos = find_policy.Find(text, delimiter, pos);
   if (found_pos != absl::string_view::npos) {
     found = absl::string_view(text.data() + found_pos,
@@ -87,7 +88,7 @@ absl::string_view ByString::Find(absl::string_view text, size_t pos) const {
     // absl::string_view.
     size_t found_pos = text.find(delimiter_[0], pos);
     if (found_pos == absl::string_view::npos)
-      return absl::string_view(text.end(), 0);
+      return absl::string_view(text.data() + text.size(), 0);
     return text.substr(found_pos, 1);
   }
   return GenericFind(text, delimiter_, pos, LiteralPolicy());
@@ -100,7 +101,7 @@ absl::string_view ByString::Find(absl::string_view text, size_t pos) const {
 absl::string_view ByChar::Find(absl::string_view text, size_t pos) const {
   size_t found_pos = text.find(c_, pos);
   if (found_pos == absl::string_view::npos)
-    return absl::string_view(text.end(), 0);
+    return absl::string_view(text.data() + text.size(), 0);
   return text.substr(found_pos, 1);
 }
 
@@ -128,9 +129,9 @@ absl::string_view ByLength::Find(absl::string_view text,
   // If the std::string is shorter than the chunk size we say we
   // "can't find the delimiter" so this will be the last chunk.
   if (substr.length() <= static_cast<size_t>(length_))
-    return absl::string_view(text.end(), 0);
+    return absl::string_view(text.data() + text.size(), 0);
 
-  return absl::string_view(substr.begin() + length_, 0);
+  return absl::string_view(substr.data() + length_, 0);
 }
 
 }  // namespace absl