diff options
author | Abseil Team <absl-team@google.com> | 2021-05-25 13:13:33 -0700 |
---|---|---|
committer | Dino Radaković <dinor@google.com> | 2021-05-25 13:18:25 -0700 |
commit | 18045c4e32cbe6217224f46261b9e2607d6e723d (patch) | |
tree | 79e3a874888d298b317e4111e342815a30272577 /absl/strings/string_view.cc | |
parent | 7e8ec214f2ceb949ad8ad33d83c194de3028ae55 (diff) |
Export of internal Abseil changes
--
d74f30ef0da7139c30a24eb6c1776bc0c257e642 by Derek Mauro <dmauro@google.com>:
Internal change
PiperOrigin-RevId: 375779441
--
25e33cde30d78dbafcb81ee3ce77c3d70c74db5a by Abseil Team <absl-team@google.com>:
Internal change
PiperOrigin-RevId: 375520720
--
46857d17d4dbc6fbd13a27dd82e14ec814dd117a by Samuel Benzaquen <sbenza@google.com>:
Add an explicit template parameter barrier to absl::HashOf.
PiperOrigin-RevId: 375103300
--
cf2bf52b9a425b0360ed1f46778f0ef1326a3658 by Abseil Team <absl-team@google.com>:
Improve string_view API compliance with C++17 std::basic_string_view.
This adds missing overloads, default values, and constexpr specifiers.
PiperOrigin-RevId: 374885658
--
41e55166dc5bd3ed7bce567c400781585d55e1ce by Derek Mauro <dmauro@google.com>:
Update CI to GCC 11.1, Bazel 4.0.0, CMake 3.20.2, and
LLVM git:7bcc0a1e399d461af7ec013ff33bc330a2de6641
PiperOrigin-RevId: 374858288
GitOrigin-RevId: d74f30ef0da7139c30a24eb6c1776bc0c257e642
Change-Id: I657c815c83522b030495ff54ca327e7012ed151e
Diffstat (limited to 'absl/strings/string_view.cc')
-rw-r--r-- | absl/strings/string_view.cc | 37 |
1 files changed, 16 insertions, 21 deletions
diff --git a/absl/strings/string_view.cc b/absl/strings/string_view.cc index c5f5de93..d596e08c 100644 --- a/absl/strings/string_view.cc +++ b/absl/strings/string_view.cc @@ -78,8 +78,8 @@ std::ostream& operator<<(std::ostream& o, string_view piece) { return o; } -string_view::size_type string_view::find(string_view s, size_type pos) const - noexcept { +string_view::size_type string_view::find(string_view s, + size_type pos) const noexcept { if (empty() || pos > length_) { if (empty() && pos == 0 && s.empty()) return 0; return npos; @@ -98,8 +98,8 @@ string_view::size_type string_view::find(char c, size_type pos) const noexcept { return result != nullptr ? result - ptr_ : npos; } -string_view::size_type string_view::rfind(string_view s, size_type pos) const - noexcept { +string_view::size_type string_view::rfind(string_view s, + size_type pos) const noexcept { if (length_ < s.length_) return npos; if (s.empty()) return std::min(length_, pos); const char* last = ptr_ + std::min(length_ - s.length_, pos) + s.length_; @@ -108,8 +108,8 @@ string_view::size_type string_view::rfind(string_view s, size_type pos) const } // Search range is [0..pos] inclusive. If pos == npos, search everything. -string_view::size_type string_view::rfind(char c, size_type pos) const - noexcept { +string_view::size_type string_view::rfind(char c, + size_type pos) const noexcept { // Note: memrchr() is not available on Windows. if (empty()) return npos; for (size_type i = std::min(pos, length_ - 1);; --i) { @@ -121,9 +121,8 @@ string_view::size_type string_view::rfind(char c, size_type pos) const return npos; } -string_view::size_type string_view::find_first_of(string_view s, - size_type pos) const - noexcept { +string_view::size_type string_view::find_first_of( + string_view s, size_type pos) const noexcept { if (empty() || s.empty()) { return npos; } @@ -138,9 +137,8 @@ string_view::size_type string_view::find_first_of(string_view s, return npos; } -string_view::size_type string_view::find_first_not_of(string_view s, - size_type pos) const - noexcept { +string_view::size_type string_view::find_first_not_of( + string_view s, size_type pos) const noexcept { if (empty()) return npos; // Avoid the cost of LookupTable() for a single-character search. if (s.length_ == 1) return find_first_not_of(s.ptr_[0], pos); @@ -153,9 +151,8 @@ string_view::size_type string_view::find_first_not_of(string_view s, return npos; } -string_view::size_type string_view::find_first_not_of(char c, - size_type pos) const - noexcept { +string_view::size_type string_view::find_first_not_of( + char c, size_type pos) const noexcept { if (empty()) return npos; for (; pos < length_; ++pos) { if (ptr_[pos] != c) { @@ -180,9 +177,8 @@ string_view::size_type string_view::find_last_of(string_view s, return npos; } -string_view::size_type string_view::find_last_not_of(string_view s, - size_type pos) const - noexcept { +string_view::size_type string_view::find_last_not_of( + string_view s, size_type pos) const noexcept { if (empty()) return npos; size_type i = std::min(pos, length_ - 1); if (s.empty()) return i; @@ -198,9 +194,8 @@ string_view::size_type string_view::find_last_not_of(string_view s, return npos; } -string_view::size_type string_view::find_last_not_of(char c, - size_type pos) const - noexcept { +string_view::size_type string_view::find_last_not_of( + char c, size_type pos) const noexcept { if (empty()) return npos; size_type i = std::min(pos, length_ - 1); for (;; --i) { |