Skip to content

Commit

Permalink
Add pair_1st_cmp struct for C++11 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
shogo82148 committed Nov 22, 2023
1 parent e109f10 commit 7a8a854
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions mecab/src/dictionary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,23 @@ int progress_bar_darts(size_t current, size_t total) {
return progress_bar("emitting double-array", current, total);
}

#if defined(__cplusplus) && __cplusplus >= 201103L
template <typename T1, typename T2>
struct pair_1st_cmp: public std::binary_function<bool, T1, T2> {
bool operator()(const std::pair<T1, T2> &x1,
const std::pair<T1, T2> &x2) {
return x1.first < x2.first;
}
};
#else
template <typename T1, typename T2>
struct pair_1st_cmp: public std::function<bool(T1, T2)> {
bool operator()(const std::pair<T1, T2> &x1,
const std::pair<T1, T2> &x2) {
return x1.first < x2.first;
}
};
#endif
} // namespace

bool Dictionary::open(const char *file, const char *mode) {
Expand Down

0 comments on commit 7a8a854

Please sign in to comment.