dimanche 12 avril 2020

Generic sort C++

I am trying to filter the strings that have the first letter identical to a given letter It doesnt work: Severity Code Description Project File Line Suppression State Error (active) E0312 no suitable user-defined conversion from "type" to "std::function" exists

vector<Movie> MovieStore::filtreaza(function<bool(const Movie&)> fct) {
    vector<Movie> rez;
    for (const auto& movie : rep.getAll()) {
        if (fct(movie)) {
            rez.push_back(movie);
        }
    }
    return rez;
}

vector<Movie> MovieStore::filtrareNumePrimaLitera(const string& letter) {
    return filtreaza([&](const Movie& m,const string& letter) {
        return m.getTitle()[0] == letter[0];
    });
}

Aucun commentaire:

Enregistrer un commentaire