struct Aa { int i0; }; std::vector<Aa*> list_; ... std::sort(list_.begin(), list_.end(), [this, &end_dates](Aa* l, Aa* r) { return l->degree_ - r->degree_; }); |
Before the sort, I promise the members of list_ are all not null, but in the sort lambda expression, when running, we will be caught by a null pointer access SIGSEGV, for example, l is null.
Well, the good shot is,
... std::sort(list_.begin(), list_.end(), [this, &end_dates](Aa* l, Aa* r) { return l->degree_ > r->degree_; }); |