Changes imported from Abseil "staging" branch:

- 6e88015f26885b66ce9b11696eb9c8d96ef7c0f6 Add ABSL_MUST_USE_RESULT to absl::StripPrefix and absl::S... by Mark Barolak <mbar@google.com>
  - 47d8de97748da346ad2a962f27389e0380a7a716 Fix missing header include when compiling with _GLIBCXX_D... by Alex Strelnikov <strel@google.com>

GitOrigin-RevId: 6e88015f26885b66ce9b11696eb9c8d96ef7c0f6
Change-Id: I8698c77d9eab81455b209a6bef4bb2d5b32ebd65
This commit is contained in:
Abseil Team 2018-01-03 09:52:58 -08:00 committed by Jon Cohen
parent 6365d1744b
commit 0271cd3557
6 changed files with 241 additions and 18 deletions

View file

@ -67,8 +67,8 @@ inline bool ConsumeSuffix(absl::string_view* str, absl::string_view expected) {
// Returns a view into the input std::string 'str' with the given 'prefix' removed,
// but leaving the original std::string intact. If the prefix does not match at the
// start of the std::string, returns the original std::string instead.
inline absl::string_view StripPrefix(absl::string_view str,
absl::string_view prefix) {
ABSL_MUST_USE_RESULT inline absl::string_view StripPrefix(
absl::string_view str, absl::string_view prefix) {
if (absl::StartsWith(str, prefix)) str.remove_prefix(prefix.size());
return str;
}
@ -78,8 +78,8 @@ inline absl::string_view StripPrefix(absl::string_view str,
// Returns a view into the input std::string 'str' with the given 'suffix' removed,
// but leaving the original std::string intact. If the suffix does not match at the
// end of the std::string, returns the original std::string instead.
inline absl::string_view StripSuffix(absl::string_view str,
absl::string_view suffix) {
ABSL_MUST_USE_RESULT inline absl::string_view StripSuffix(
absl::string_view str, absl::string_view suffix) {
if (absl::EndsWith(str, suffix)) str.remove_suffix(suffix.size());
return str;
}