Skip to content

Instantly share code, notes, and snippets.

@liuml07
Last active February 8, 2022 15:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save liuml07/6362835 to your computer and use it in GitHub Desktop.
Save liuml07/6362835 to your computer and use it in GitHub Desktop.
The missing std::string::ends_with(string)
bool ends_with(const std::string &str, const std::string &ending) {
if (str.length() < ending.length())
return false;
return str.compare(str.length() - ending.length(), ending.length(), ending) == 0;
}
@liuml07
Copy link
Author

liuml07 commented Aug 28, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment