Skip to content

Instantly share code, notes, and snippets.

@ju1ion
Last active June 1, 2016 09:37
Show Gist options
  • Save ju1ion/869b973d9bc5afaeec0a9d56b1d63187 to your computer and use it in GitHub Desktop.
Save ju1ion/869b973d9bc5afaeec0a9d56b1d63187 to your computer and use it in GitHub Desktop.
C++ String ends_with without boost
static bool endswithA(std::string const &InputString, std::string const &compareString)
{
if (InputString.length() >= compareString.length()) {
return (0 == InputString.compare(InputString.length() - compareString.length(), compareString.length(), compareString));
}
else {
return false;
}
};
static bool endswithW(std::wstring const &InputString, std::wstring const &compareString)
{
if (InputString.length() >= compareString.length()) {
return (0 == InputString.compare(InputString.length() - compareString.length(), compareString.length(), compareString));
}
else {
return false;
}
};
#ifdef UNICODE
#define endswith endswithW
#else
#define endswith endswithA
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment