Merge pull request #3663 from stweil/clang7

Allow compilation with clang-7
This commit is contained in:
Egor Pugin 2021-11-28 23:02:41 +03:00 committed by GitHub
commit bb155a1bb4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 8 deletions

View File

@ -252,7 +252,7 @@ bool Serialize(FILE *fp, const std::vector<T> &data) {
uint32_t size = data.size();
if (fwrite(&size, sizeof(size), 1, fp) != 1) {
return false;
} else if constexpr (std::is_class_v<T>) {
} else if constexpr (std::is_class<T>::value) {
// Serialize a tesseract class.
for (auto &item : data) {
if (!item.Serialize(fp)) {

View File

@ -104,7 +104,7 @@ public:
} else if (size > 50000000) {
// Arbitrarily limit the number of elements to protect against bad data.
return false;
} else if constexpr (std::is_same_v<T, std::string>) {
} else if constexpr (std::is_same<T, std::string>::value) {
// Deserialize a string.
// TODO: optimize.
data.resize(size);
@ -113,7 +113,7 @@ public:
return false;
}
}
} else if constexpr (std::is_class_v<T>) {
} else if constexpr (std::is_class<T>::value) {
// Deserialize a tesseract class.
// TODO: optimize.
data.resize(size);
@ -122,7 +122,7 @@ public:
return false;
}
}
} else if constexpr (std::is_pointer_v<T>) {
} else if constexpr (std::is_pointer<T>::value) {
// Deserialize pointers.
// TODO: optimize.
data.resize(size);
@ -163,21 +163,21 @@ public:
uint32_t size = data.size();
if (!Serialize(&size)) {
return false;
} else if constexpr (std::is_same_v<T, std::string>) {
} else if constexpr (std::is_same<T, std::string>::value) {
// Serialize strings.
for (auto string : data) {
if (!Serialize(string)) {
return false;
}
}
} else if constexpr (std::is_class_v<T>) {
} else if constexpr (std::is_class<T>::value) {
// Serialize a tesseract class.
for (auto &item : data) {
if (!item.Serialize(this)) {
return false;
}
}
} else if constexpr (std::is_pointer_v<T>) {
} else if constexpr (std::is_pointer<T>::value) {
// Serialize pointers.
for (auto &item : data) {
uint8_t non_null = (item != nullptr);

View File

@ -665,7 +665,8 @@ void UNICHARSET::unichar_insert(const char *const unichar_repr,
encode_string(str, true, &encoding, nullptr, nullptr)) {
return;
}
auto &u = unichars.emplace_back();
unichars.emplace_back();
auto &u = unichars.back();
int index = 0;
do {
if (index >= UNICHAR_LEN) {