Error when compiling and using extract function #65
-
Hello, I discovered this library because I need fuzzy search in my program. I have the case that I am comparing one string against a multiple string, so I am using the extract function as shown in the readme: template <typename Sentence1,
typename Iterable, typename Sentence2 = typename Iterable::value_type>
std::vector<std::pair<Sentence2, double>>
extract(const Sentence1& query, const Iterable& choices, const double score_cutoff = 0.0)
{
std::vector<std::pair<Sentence2, double>> results;
rapidfuzz::fuzz::CachedRatio<typename Sentence1::value_type> scorer(query);
for (const auto& choice : choices) {
double score = scorer.similarity(choice, score_cutoff);
if (score >= score_cutoff) {
results.emplace_back(choice, score);
}
}
return results;
} I am using it like this: auto search_results = extract<std::string, std::vector<std::string>>(query, terms); However, I encouter this compilation error:
Here are my build informations: I tried using a non-templated version, but I still get this error. Any idea on how to resolve this ? Thank you |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
Are you sure that you are already using the docs fix from: b23c9ad
since I provide template deduction guides |
Beta Was this translation helpful? Give feedback.
-
Seeing your error message, you are indeed using the older example code. |
Beta Was this translation helpful? Give feedback.
-
Forgot to enable them on the msvc compiler, where |
Beta Was this translation helpful? Give feedback.
-
Thank you, the fix 0000f4e along with @maxbachmann answer work. |
Beta Was this translation helpful? Give feedback.
Are you sure that you are already using the docs fix from: b23c9ad
Note that with C++20 it would be enough to use:
since I provide template deduction guides