Does name_compare()
calls the default construction or the operator()
of class name_compare
in sort(vs.begin(), vs.end(), name_compare());
?
I think it's the first one.Am i right?
I would be thankful for any hint on this question.
struct Record {
string name;
// ...
};
struct name_compare { // compare Records using "name" as the key
bool operator()(const Record& a, const Record& b) const
{ return a.name<b.name; }
};
void f(vector<Record>& vs)
{
sort(vs.begin(), vs.end(), name_compare());
// ...
}
Aucun commentaire:
Enregistrer un commentaire