Export of internal Abseil changes

--
5315e7b98905922e779798f3168d98343438c134 by Derek Mauro <dmauro@google.com>:

Fix absl::string_view::copy to throw std::out_of_range when pos > size().

Fixes https://github.com/abseil/abseil-cpp/issues/362

PiperOrigin-RevId: 261907364
GitOrigin-RevId: 5315e7b98905922e779798f3168d98343438c134
Change-Id: Ia8ab971c54f287411f6ea4b99f9c666c989c33fd
This commit is contained in:
Abseil Team 2019-08-06 07:13:35 -07:00 committed by CJ Johnson
parent c5c4db4f51
commit 67222ffc4c
3 changed files with 17 additions and 13 deletions

View file

@ -77,18 +77,6 @@ std::ostream& operator<<(std::ostream& o, string_view piece) {
return o;
}
string_view::size_type string_view::copy(char* buf, size_type n,
size_type pos) const {
size_type ulen = length_;
assert(pos <= ulen);
size_type rlen = std::min(ulen - pos, n);
if (rlen > 0) {
const char* start = ptr_ + pos;
std::copy(start, start + rlen, buf);
}
return rlen;
}
string_view::size_type string_view::find(string_view s, size_type pos) const
noexcept {
if (empty() || pos > length_) {