I have a problem, using STL algorithm with QList: while executing it crashes. Debuger takes one more step into lambda, so before to crash entry is . (So, if list is empty is crashes at 1 iteration, if list has 1 element - at 2 iteration etc.).
void FindDialog::findEntries()
{
QList<StudentEntry> searchResult;
condition = [this] (const StudentEntry &entry) -> bool {
// crashes here
return entry.name.getSurname() == surnameEdt1->text() &&
entry.group.getValue() == groupEdt->text();
};
std::copy_if(model->getStudentEntryList().begin(),
model->getStudentEntryList().end(),
searchResult.begin(),
condition);
}
How can I solve the problem?
std::back_inserter(searchResult)as your output iteratorstd::list. Have you looked at correct examples demonstrating the use ofcopy_if?