"A variable with static storage duration cannot be captured in a lambda"

  • Thread starter Thread starter Danzellen
  • Start date Start date
D

Danzellen

Guest
What I'm trying to do is sort a vector based on a variable known as "result time". I have the function that will help me sort it, but I'm getting an error:

"A variable with static storage duration cannot be captured in a lambda".

The bolded part is where the error is showing up. I'm confused as to why this is happening. Before I added an MFC GUI to the project, this worked just fine. Does anyone know what the problem might be and how I could fix it?

Schedule mySchedule; //declared globally at the start of the program.

std::sort(taskvector2.begin(), taskvector2.end(),
[&mySchedule](Schedule::Tracker* schedule1, Schedule::Tracker* schedule2)
{
return mySchedule.isSmaller(schedule1->m_resulttime, schedule2->m_resulttime);
}
);

Continue reading...
 
Back
Top