It's been a while, haven't used lists much, but I'm trying to remove a specific element from a list I have.
I iterate through the list until my iterator is pointing to the correct element, then I call the erase member function, passing my iterator as an argument to the erase function. When that piece of code runs, it causes a segfault. Here's what it looks like:
Code:
for(iter=openlist.begin();iter!=openlist.end();iter++)
		{
			temp=iter->get_pos();
			if(disp.x==temp.x&&disp.y==temp.y)
			openlist.erase(iter);
		}
The temp and disp variables are structs that just contain two integers(x and y). The openlist is my list(obviously), and I want to remove the element in openlist that has the same coordinates as the set found in disp. The list contains a class I made. I'm wondering if there's a better, easier way to remove that specific element with those coordinates(and yes, the coordinates appear only once)? Or is there a reason that's giving me a segmentation fault? Any help or pointers are appreciated, thanks.