I want to implement a function which iterates over a list and returns a pointer in case of a match. I wrote:
std::list<JobEntry> jobs;
JobsList::JobEntry *JobsList::getJobById(int jobId) {
for (auto const& job : jobs) {
if (job.pid==jobId) {
return std::addressof(*job);
}
}
return nullptr;
}
But this doesn't work, how can I do it?
Aucun commentaire:
Enregistrer un commentaire