Skip to content

Commit

Permalink
Handle UChar != char16_t
Browse files Browse the repository at this point in the history
  • Loading branch information
TinoDidriksen committed Jul 1, 2021
1 parent 152691a commit f45b149
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
8 changes: 8 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ AX_CHECK_COMPILE_FLAG([-std=c++20], [CXXFLAGS="$CXXFLAGS -std=c++20"], [
])
])

AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <unicode/umachine.h>
#include <type_traits>
]],[[
using namespace std;
static_assert(!is_same<UChar,char16_t>::value, "UChar == char16_t");
]])], [AC_DEFINE([UCHAR_NOT_CHAR16_T], [1], [UChar != char16_t])])

AC_CONFIG_FILES([
apertium-anaphora.pc
Makefile
Expand Down
11 changes: 11 additions & 0 deletions src/parse_arx.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@ struct markable_pattern
int head;
};

#ifdef UCHAR_NOT_CHAR16_T
namespace std {
template<> struct hash<UString> {
size_t operator ()(const UString& str) const {
auto u16 = reinterpret_cast<const std::u16string*>(&str);
return std::hash<std::u16string>{}(*u16);
}
};
}
#endif

typedef vector< vector<markable_pattern> > acceptable_patterns;

typedef unordered_map< UString, unordered_map<UString, acceptable_tags> > parameters_datatype;
Expand Down

0 comments on commit f45b149

Please sign in to comment.