From bc95fedbaa083d557840db6ac2cbf14e2a3eccce Mon Sep 17 00:00:00 2001 From: Kenneth Heafield Date: Fri, 20 May 2011 16:19:04 -0400 Subject: kenlm update including being nicer to NFS --- klm/util/string_piece.hh | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'klm/util/string_piece.hh') 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 +#include + +// 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(), -- cgit v1.2.3