diff options
author | Patrick Simianer <p@simianer.de> | 2014-01-28 15:35:31 +0100 |
---|---|---|
committer | Patrick Simianer <p@simianer.de> | 2014-01-28 15:35:31 +0100 |
commit | 9c9ba8954358f791a818b3eefda2c0eb805bbd97 (patch) | |
tree | 0153350406bf1c9c6aafa8e5da5d4b3feb9cd0c9 /klm/util/string_piece.hh | |
parent | 1b0d40959f529b67db3b9d10dbf93101e0c65c7c (diff) | |
parent | 19de646f60d4fb52ddd26d25e06f50f8717fd988 (diff) |
resolv conflict in mira
Diffstat (limited to 'klm/util/string_piece.hh')
-rw-r--r-- | klm/util/string_piece.hh | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/klm/util/string_piece.hh b/klm/util/string_piece.hh index 9cf4c7f6..84431db1 100644 --- a/klm/util/string_piece.hh +++ b/klm/util/string_piece.hh @@ -74,6 +74,12 @@ inline bool operator!=(const StringPiece& x, const StringPiece& y) { #endif // old version of ICU U_NAMESPACE_BEGIN + +inline bool starts_with(const StringPiece& longer, const StringPiece& prefix) { + int longersize = longer.size(), prefixsize = prefix.size(); + return longersize >= prefixsize && std::memcmp(longer.data(), prefix.data(), prefixsize) == 0; +} + #else #include <algorithm> @@ -212,7 +218,7 @@ class StringPiece { StringPiece substr(size_type pos, size_type n = npos) const; static int wordmemcmp(const char* p, const char* p2, size_type N) { - return memcmp(p, p2, N); + return std::memcmp(p, p2, N); } }; @@ -227,6 +233,10 @@ inline bool operator!=(const StringPiece& x, const StringPiece& y) { return !(x == y); } +inline bool starts_with(const StringPiece& longer, const StringPiece& prefix) { + return longer.starts_with(prefix); +} + #endif // HAVE_ICU undefined inline bool operator<(const StringPiece& x, const StringPiece& y) { |