Last active
June 1, 2016 09:37
-
-
Save ju1ion/869b973d9bc5afaeec0a9d56b1d63187 to your computer and use it in GitHub Desktop.
C++ String ends_with without boost
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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