summaryrefslogtreecommitdiff
path: root/klm/util/string_piece.hh
diff options
context:
space:
mode:
authorKenneth Heafield <kheafiel@cluster12.lti.ece.cmu.local>2011-05-20 16:19:04 -0400
committerKenneth Heafield <kheafiel@cluster12.lti.ece.cmu.local>2011-05-20 16:19:04 -0400
commitbc95fedbaa083d557840db6ac2cbf14e2a3eccce (patch)
tree00717d119814232577f7345ddbf2f224d58911e8 /klm/util/string_piece.hh
parent066dcbd87b6a59d4ef032001763eebf620fe4702 (diff)
kenlm update including being nicer to NFS
Diffstat (limited to 'klm/util/string_piece.hh')
-rw-r--r--klm/util/string_piece.hh19
1 files changed, 18 insertions, 1 deletions
diff --git a/klm/util/string_piece.hh b/klm/util/string_piece.hh
index e5b16e38..5de053aa 100644
--- a/klm/util/string_piece.hh
+++ b/klm/util/string_piece.hh
@@ -60,6 +60,23 @@
#ifdef HAVE_ICU
#include <unicode/stringpiece.h>
+#include <unicode/uversion.h>
+
+// Old versions of ICU don't define operator== and operator!=.
+#if (U_ICU_VERSION_MAJOR_NUM < 4) || ((U_ICU_VERSION_MAJOR_NUM == 4) && (U_ICU_VERSION_MINOR_NUM < 4))
+#warning You are using an old version of ICU. Consider upgrading to ICU >= 4.6.
+inline bool operator==(const StringPiece& x, const StringPiece& y) {
+ if (x.size() != y.size())
+ return false;
+
+ return std::memcmp(x.data(), y.data(), x.size()) == 0;
+}
+
+inline bool operator!=(const StringPiece& x, const StringPiece& y) {
+ return !(x == y);
+}
+#endif // old version of ICU
+
U_NAMESPACE_BEGIN
#else
@@ -209,7 +226,7 @@ inline bool operator!=(const StringPiece& x, const StringPiece& y) {
return !(x == y);
}
-#endif
+#endif // HAVE_ICU undefined
inline bool operator<(const StringPiece& x, const StringPiece& y) {
const int r = std::memcmp(x.data(), y.data(),