Skip to content

Commit

Permalink
Merge pull request tesseract-ocr#3663 from stweil/clang7
Browse files Browse the repository at this point in the history
Allow compilation with clang-7
  • Loading branch information
egorpugin authored Nov 28, 2021
2 parents eb089c1 + ffe2038 commit bb155a1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/ccutil/helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
12 changes: 6 additions & 6 deletions src/ccutil/serialis.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class TESS_API TFile {
} 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);
Expand All @@ -113,7 +113,7 @@ class TESS_API TFile {
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);
Expand All @@ -122,7 +122,7 @@ class TESS_API TFile {
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);
Expand Down Expand Up @@ -163,21 +163,21 @@ class TESS_API TFile {
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);
Expand Down
3 changes: 2 additions & 1 deletion src/ccutil/unicharset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit bb155a1

Please sign in to comment.