0

Im getting a Segfault at this line:

v.erase(std::remove_if(v.begin(),elem.end(),
         [](Elem  * elem ){return elem->busy_ == false ;}));

Investigating with gdb brought:

(gdb) print v.begin()
$6 = 0x842b120
(gdb) print v.end()
$7 = 0x0
(gdb) print v.back()
$8 = (Elem *) 0x842b120

Valgrind does not detect any problems (except for the segfault). I exchanged the code in question for:

    auto begin = v.begin();
    while( begin != v.end() )
     {
        if((*begin)->busy_ == false) begin=v.erase(begin);
        else begin++;
     }       

what am I missing?

loreson
  • 122
  • 1
  • 8

0 Answers0