Skip to content

Commit f66d330

Browse files
WhiredPlancklotem
authored andcommitted
fix(algo, dict): add an extra set of parenthesis to std::min ...
... to prevent min macro invocation on Windows.
1 parent 24e1612 commit f66d330

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

src/rime/algo/syllabifier.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ int Syllabifier::BuildSyllableGraph(const string &input,
113113
if (it == spellings.end()) {
114114
spellings.insert({syllable_id, props});
115115
} else {
116-
it->second.type = std::min(it->second.type, props.type);
116+
it->second.type = (std::min)(it->second.type, props.type);
117117
}
118118
// let end_vertex_type be the best (smaller) type of spelling
119119
// that ends at the vertex

src/rime/dict/corrector.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ Distance EditDistanceCorrector::LevenshteinDistance(const std::string &s1, const
172172
last_diagonal + SubstCost(s1[y - 1], s2[x - 1])
173173
};
174174

175-
column[y] = std::min(possibilities);
175+
column[y] = (std::min)(possibilities);
176176
last_diagonal = old_diagonal;
177177
}
178178
}
@@ -199,15 +199,15 @@ Distance EditDistanceCorrector::RestrictedDistance(const std::string& s1,
199199
for(size_t i = 1; i <= len1; ++i) {
200200
auto min_d = threshold + 1;
201201
for(size_t j = 1; j <= len2; ++j) {
202-
d[index(i, j)] = std::min({
202+
d[index(i, j)] = (std::min)({
203203
d[index(i - 1, j)] + 2,
204204
d[index(i, j - 1)] + 2,
205205
d[index(i - 1, j - 1)] + SubstCost(s1[i - 1], s2[j - 1])
206206
});
207207
if (i > 1 && j > 1 && s1[i - 2] == s2[j - 1] && s1[i - 1] == s2[j - 2]) {
208-
d[index(i, j)] = std::min(d[index(i, j)], d[index(i - 2, j - 2)] + 2);
208+
d[index(i, j)] = (std::min)(d[index(i, j)], d[index(i - 2, j - 2)] + 2);
209209
}
210-
min_d = std::min(min_d, d[index(i, j)]);
210+
min_d = (std::min)(min_d, d[index(i, j)]);
211211
}
212212
// early termination: do not continue if too far
213213
if (min_d > threshold)

0 commit comments

Comments
 (0)